Skip to content

Commit b520f51

Browse files
committed
feat(template): Add ability for developers to override the template
Template is no longer included in directive. There is a seperate file and also a javascript class to load the template into . Also did a rather significant refactoring of the code. BREAKING CHANGE: must include datetimepicker.template.js in the page to load the template.
1 parent 7b70440 commit b520f51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+748
-707
lines changed

.jscsrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"disallowDanglingUnderscores": { "allExcept": ["_$compile_", "_$rootScope_"] },
33
"disallowMultipleVarDecl": "strict",
44
"preset": "crockford",
5+
"requireFunctionDeclarations": true,
56
"requireMultipleVarDecl": null,
67
"requireVarDeclFirst": null,
78
"validateIndentation": 2

.jshintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
1414
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
1515
"indent" : 2, // {int} Number of spaces to use for indentation
16-
"latedef" : true, // true: Require variables/functions to be defined before being used
16+
"latedef" : "nofunc", // true: Require variables/functions to be defined before being used
1717
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
1818
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
1919
"noempty" : true, // true: Prohibit use of empty blocks

.travis.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
language: node_js
21
sudo: false
2+
language: node_js
3+
cache:
4+
directories:
5+
- node_modules
6+
notifications:
7+
email: false
38
node_js:
4-
- '4.1'
9+
- '5'
10+
before_install:
11+
- export DISPLAY=:99.0
12+
- sh -e /etc/init.d/xvfb start
13+
- npm i -g npm@^3.0.0
14+
before_script:
15+
- npm prune
16+
script:
17+
- npm run test
18+
after_success:
19+
- npm run semantic-release
520
branches:
621
except:
7-
- gh-pages
8-
before_install:
9-
- export DISPLAY=:99.0
10-
- sh -e /etc/init.d/xvfb start
11-
deploy:
12-
provider: npm
13-
14-
api_key:
15-
secure: uS3oRid+vZK5nKVqd5YNhAJGyNbJAdw0/3gHZB67ynG9HWEr1Y026uzf0Ext6XT9LHjCgGPEaN1Lyjr+LJRYt+LV7HYDVm09RrEIqJm+2+2qwQIpVtxRyr6xCr1b2EFFrYqwZPe33/Y0WradbaqQ0EKLBSygCNL8tzC7b1yxD6U=
16-
on:
17-
tags: true
18-
repo: dalelotts/angular-bootstrap-datetimepicker
19-
branch: master
22+
- "/^v\\d+\\.\\d+\\.\\d+$/"
23+
- gh-pages

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,33 @@ Native AngularJS datetime picker directive styled by Twitter Bootstrap 3
1515

1616
[Home / demo page](http://dalelotts.github.io/angular-bootstrap-datetimepicker/)
1717

18+
## Upgrading from 0.4.0 or earlier
1819

19-
#Dependencies
20+
The template used by this directive has been separated from the directive to allow the developer to override
21+
the template (i.e. use font-awesome styles in the template rather than glyphicons). As a result, you now
22+
need to include another javascript file in the page
23+
24+
```html
25+
<script type="text/javascript" src="node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.templates.js"></script>
26+
```
27+
28+
If you wan to override the template used by this directive, simply populate the ```$templateCache``` with your own template.
29+
30+
# Formatting the date in an input box
31+
32+
Use the [angular-date-time-input](https://github.com/dalelotts/angular-date-time-input) directive to format the
33+
display of a date in an input box or allow users to enter a valid date with the keyboard.
34+
35+
# Dependencies
2036

2137
Requires:
2238
* AngularJS 1.4.x or higher (1.0.x will not work)
2339
* moment.js 2.8.3 or higher for date parsing and formatting
2440
* bootstrap's glyphicons for arrows (Can be overridden in css)
2541

2642
optional:
27-
* bootstrap's dropdown component (`dropdowns.less`)
43+
* bootstrap's dropdown component (`dropdowns.less` or `bootstrap.css` )
44+
* bootstrap's javascript (`bootstrap.js` )
2845

2946
#Testing
3047
This directive was written using TDD and all enhancements and changes have related tests.
@@ -58,9 +75,9 @@ Add the css:
5875
Load the script files in your application:
5976
```html
6077
<script type="text/javascript" src="node_modules/moment/moment.js"></script>
61-
<script type="text/javascript" src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
6278
<script type="text/javascript" src="node_modules/angular/angular.js"></script>
6379
<script type="text/javascript" src="node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.js"></script>
80+
<script type="text/javascript" src="node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.templates.js"></script>
6481
```
6582

6683
Add the date module as a dependency to your application module:
@@ -77,7 +94,6 @@ Apply the directive to your form elements:
7794

7895
## Callback functions
7996

80-
8197
### before-render
8298
Attribute on datetimepicker element
8399

@@ -338,6 +354,8 @@ $scope.beforeRenderEndDate = function($view, $dates, $leftDate, $upDate, $rightD
338354
```
339355
Then in the controller two functions must be added. Each one is related to the concerned date. They update the selectable status of each displayed date based on the range values. The time is also taken into account.
340356

357+
## Screen reader support
358+
341359
## I18N / l10n support
342360

343361
All internationalization is handled by Moment.js, see Moment's documentation for details.

contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ If you are submitting a bug, please create a [jsfiddle](http://jsfiddle.net/) de
66
Contributing code
77
=================
88

9-
To contribute, fork the library and install grunt and dependencies. You need [node](http://nodejs.org/); use [nvm](https://github.com/creationix/nvm) or [nenv](https://github.com/ryuone/nenv) to install it.
9+
To contribute, fork the library and install gulp and dependencies. You need [node](http://nodejs.org/); use [nvm](https://github.com/creationix/nvm) or [nenv](https://github.com/ryuone/nenv) to install it.
1010

1111
```bash
1212
git clone https://github.com/dalelotts/angular-bootstrap-datetimepicker.git
1313
cd angular-bootstrap-datetimepicker
14-
npm install -g grunt-cli
14+
npm install -g gulp
1515
npm install
1616
git checkout develop # all patches against develop branch, please!
1717
gulp # this runs jscs, jshint, complexity checks, and unit tests.

demo/demo-app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
angular.module('demo',
33
[
44
'demo.demoController',
5-
'ui.bootstrap.datetimepicker'
5+
'ui.bootstrap.datetimepicker',
6+
'ui.dateTimeInput'
67
])
78
.config([
89
function () {

demo/demo-controller.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$scope.controllerName = 'demoController';
1717

1818
/* Bindable functions
19-
-----------------------------------------------*/
19+
-----------------------------------------------*/
2020
$scope.beforeRender = beforeRender;
2121
$scope.changeConfig = changeConfig;
2222
$scope.checkboxOnTimeSet = checkboxOnTimeSet;
@@ -38,14 +38,14 @@
3838

3939
$scope.data = {
4040
guardians: [
41-
{
42-
name: 'Peter Quill',
43-
dob: null
44-
},
45-
{
46-
name: 'Groot',
47-
dob: null
48-
}
41+
{
42+
name: 'Peter Quill',
43+
dob: null
44+
},
45+
{
46+
name: 'Groot',
47+
dob: null
48+
}
4949
]
5050
};
5151

@@ -88,13 +88,13 @@
8888
$log.info(newDate);
8989
$log.info(oldDate);
9090
angular.element('#guardian' + $index).dropdown('toggle');
91-
};
91+
}
9292

9393
function beforeRender($dates) {
9494
var index = Math.ceil($dates.length / 2);
9595
$log.info(index);
9696
$dates[index].selectable = false;
97-
};
97+
}
9898

9999
function configFunction() {
100100
return {startView: 'month'};

demo/index.html

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313
<title>Angular Bootstrap - Date Time Picker Demo</title>
1414
<base href="..">
1515

16-
<link rel="apple-touch-icon" sizes="57x57" href="/demo/favicons/apple-touch-icon-57x57.png">
17-
<link rel="apple-touch-icon" sizes="60x60" href="/demo/favicons/apple-touch-icon-60x60.png">
18-
<link rel="apple-touch-icon" sizes="72x72" href="/demo/favicons/apple-touch-icon-72x72.png">
19-
<link rel="apple-touch-icon" sizes="76x76" href="/demo/favicons/apple-touch-icon-76x76.png">
20-
<link rel="apple-touch-icon" sizes="114x114" href="/demo/favicons/apple-touch-icon-114x114.png">
21-
<link rel="apple-touch-icon" sizes="120x120" href="/demo/favicons/apple-touch-icon-120x120.png">
22-
<link rel="apple-touch-icon" sizes="144x144" href="/demo/favicons/apple-touch-icon-144x144.png">
23-
<link rel="apple-touch-icon" sizes="152x152" href="/demo/favicons/apple-touch-icon-152x152.png">
24-
<link rel="apple-touch-icon" sizes="180x180" href="/demo/favicons/apple-touch-icon-180x180.png">
25-
<link rel="icon" type="image/png" href="/demo/favicons/favicon-32x32.png" sizes="32x32">
26-
<link rel="icon" type="image/png" href="/demo/favicons/android-chrome-192x192.png" sizes="192x192">
27-
<link rel="icon" type="image/png" href="/demo/favicons/favicon-96x96.png" sizes="96x96">
28-
<link rel="icon" type="image/png" href="/demo/favicons/favicon-16x16.png" sizes="16x16">
29-
<link rel="manifest" href="/demo/favicons/manifest.json">
3016
<meta name="msapplication-TileColor" content="#da532c">
3117
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
3218
<meta name="theme-color" content="#ffffff">
@@ -42,6 +28,8 @@
4228
<script type="text/javascript" src="demo/demo-app.js"></script>
4329
<script type="text/javascript" src="demo/demo-controller.js"></script>
4430
<script type="text/javascript" src="src/js/datetimepicker.js"></script>
31+
<script type="text/javascript" src="src/js/datetimepicker.templates.js"></script>
32+
<script type="text/javascript" src="https://cdn.rawgit.com/dalelotts/angular-date-time-input/v1.0.0/src/dateTimeInput.js"></script>
4533
<style>
4634
.datetimepicker {
4735
width: 400px;
@@ -89,7 +77,7 @@ <h4>No formatting</h4>
8977
</div>
9078
<div class="col-sm-6">
9179
<h3>Drop-down Datetime with input box</h3>
92-
<h4>Localized formatting <code>Not implemented yet</code></h4>
80+
<h4>Localized formatting using <a href="https://github.com/dalelotts/angular-date-time-input"><code>angular-date-time-input</code></a> directive</h4>
9381

9482
<p>Notice that you CAN enter a date with the keyboard.</p>
9583

@@ -102,7 +90,7 @@ <h4>Localized formatting <code>Not implemented yet</code></h4>
10290
<a class="dropdown-toggle" id="dropdown2" role="button" data-toggle="dropdown" data-target="#"
10391
href="#">
10492
<div class="input-group">
105-
<input type="text" class="form-control" data-ng-model="data.dateDropDownInput">
93+
<input type="text" class="form-control" data-ng-model="data.dateDropDownInput" data-date-time-input="YYYY-MM-DD HH:mm a">
10694
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
10795
</div>
10896
</a>

gulpfile.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ var lodash = require('lodash');
1111
var paths = require('./paths');
1212
var plato = require('plato');
1313
var Server = require('karma').Server;
14+
var path = require('path');
1415

1516
gulp.task('build-css', ['scss'], function () {
1617
var Comb = require('csscomb');
17-
var config = require('./config/csscomb.json');
18+
var config = require('./.csscomb.json');
1819
var comb = new Comb(config);
1920
comb.processPath('./src/css/');
2021
});
@@ -93,6 +94,21 @@ var testConfig = function (options) {
9394
return lodash.assign(options, travisOptions);
9495
};
9596

97+
gulp.task('templatecache', function () {
98+
var templateCache = require('gulp-angular-templatecache');
99+
var htmlMin = require('gulp-htmlmin');
100+
101+
return gulp
102+
.src('src/templates/**/*.html')
103+
.pipe(htmlMin({removeComments: true}))
104+
.pipe(templateCache('datetimepicker.templates.js', {
105+
base: path.join(__dirname, 'src'),
106+
module: 'ui.bootstrap.datetimepicker'
107+
}))
108+
.pipe(gulp.dest('src/js'));
109+
});
110+
111+
96112
gulp.task('tdd', function (done) {
97113
gulp.watch(paths.all.concat(paths.scss), ['jscs', 'lint', 'build-css']);
98114

@@ -110,7 +126,7 @@ gulp.task('tdd', function (done) {
110126
});
111127

112128

113-
gulp.task('test', function (done) {
129+
gulp.task('test', ['jscs', 'lint', 'csslint'], function (done) {
114130

115131
var config = testConfig(
116132
{
@@ -125,4 +141,4 @@ gulp.task('test', function (done) {
125141
});
126142

127143

128-
gulp.task('default', ['jscs', 'lint', 'complexity', 'csslint', 'test']);
144+
gulp.task('default', ['complexity', 'test']);

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module.exports = function (config) {
9090
// - Safari (only Mac)
9191
// - PhantomJS
9292
// - IE (only Windows)
93-
browsers: ['Chrome'],
93+
browsers: ['PhantomJS'],
9494

9595

9696
// If browser does not capture in given timeout [ms], kill it

package.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.4.0",
44
"description": "This directive allows you to add a datetime-picker to your form elements.",
55
"keywords": [
6-
"anguar",
6+
"angular",
77
"calendar",
88
"date picker",
99
"date",
@@ -20,48 +20,49 @@
2020
"homepage": "http://dalelotts.github.io/angular-bootstrap-datetimepicker",
2121
"main": "src/js/datetimepicker.js",
2222
"dependencies": {
23-
"angular": "^1.4.7",
24-
"moment": "^2.10.6"
23+
"angular": "^1.4.9",
24+
"moment": "^2.11.1"
2525
},
2626
"devDependencies": {
27-
"angular-mocks": "^1.4.7",
28-
"autoprefixer": "^6.1.0",
29-
"bootstrap": "^3.3.5",
30-
"bower": "latest",
31-
"commitizen": "^2.4.6",
27+
"angular-mocks": "^1.4.9",
28+
"autoprefixer": "^6.3.1",
29+
"bootstrap": "^3.3.6",
30+
"commitizen": "^2.5.0",
3231
"csscomb": "^3.1.8",
3332
"csslint": "^0.10.0",
34-
"cz-conventional-changelog": "^1.1.4",
35-
"del": "^2.1.0",
33+
"cz-conventional-changelog": "^1.1.5",
34+
"del": "^2.2.0",
3635
"grunt": "^0.4.4",
37-
"grunt-bump": "^0.6.0",
36+
"grunt-bump": "^0.7.0",
3837
"gulp": "^3.8.11",
38+
"gulp-angular-templatecache": "^1.8.0",
3939
"gulp-csslint": "^0.2.0",
40+
"gulp-htmlmin": "^1.3.0",
4041
"gulp-jscs": "^3.0.0",
41-
"gulp-jshint": "^1.12.0",
42+
"gulp-jshint": "^2.0.0",
4243
"gulp-postcss": "^6.0.1",
43-
"gulp-sass": "^2.1.0",
44-
"gulp-scss-lint": "^0.3.8",
44+
"gulp-sass": "^2.1.1",
45+
"gulp-scss-lint": "^0.3.9",
4546
"gulp-scss-lint-stylish": "^1.0.0",
4647
"gulp-sourcemaps": "^1.6.0",
47-
"jasmine-core": "^2.3.4",
48-
"jquery": "^2.1.4",
49-
"jshint": "^2.8.0",
48+
"jasmine-core": "^2.4.1",
49+
"jquery": "^2.2.0",
50+
"jshint": "^2.9.1",
5051
"jshint-stylish": "^2.1.0",
51-
"karma": "^0.13.15",
52-
"karma-chrome-launcher": "^0.2.0",
52+
"karma": "^0.13.19",
53+
"karma-chrome-launcher": "^0.2.2",
5354
"karma-coverage": "^0.5.0",
5455
"karma-firefox-launcher": "^0.1.7",
5556
"karma-jasmine": "^0.3.6",
5657
"karma-phantomjs-launcher": "^0.2.1",
5758
"karma-threshold-reporter": "^0.1.12",
58-
"lodash": "^3.10.1",
59+
"lodash": "^4.1.0",
5960
"matchdep": "^1.0.0",
6061
"phantomjs": "^1.9.18",
6162
"plato": "^1.5.0",
6263
"run-browser": "^2.0.2",
63-
"semantic-release": "^4.3.5",
64-
"tape": "^4.2.0"
64+
"semantic-release": "^6.2.0",
65+
"tape": "^4.4.0"
6566
},
6667
"scripts": {
6768
"test": "npm run test-browserify && gulp",

src/css/datetimepicker.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)