Skip to content

Commit 054f755

Browse files
committed
First commit to convert to gulp - fixed jshint issues with double quoted strings
1 parent ca2a5e8 commit 054f755

28 files changed

+320
-187
lines changed

Diff for: .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" : true, // 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+
}

Diff for: demo/demo-controller.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ angular.module('demo.demoController', [])
77
'use strict';
88
$scope.controllerName = 'demoController';
99

10-
moment.locale("en");
10+
moment.locale('en');
1111

1212
$scope.data = {
1313
guardians: [
@@ -26,7 +26,7 @@ angular.module('demo.demoController', [])
2626
$scope.data.checked = false;
2727
};
2828

29-
$scope.inputOnTimeSet = function (newDate, oldDate) {
29+
$scope.inputOnTimeSet = function (newDate) {
3030
// If you are not using jQuery or bootstrap.js,
3131
// this will throw an error.
3232
// However, can write this function to take any

Diff for: gulpfile.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*jslint node: true */
2+
'use strict';
3+
4+
var gulp = require('gulp');
5+
var jshint = require('gulp-jshint');
6+
var karma = require('karma').server;
7+
8+
9+
var paths = {
10+
scripts: ['gulpfile.js', 'src/**/*.js', 'test/**/*.js', 'demo/**/*.js'],
11+
karmaConfig: __dirname + '/karma.conf.js'
12+
};
13+
14+
gulp.task('test', function (done) {
15+
karma.start({
16+
configFile: paths.karmaConfig,
17+
singleRun: true
18+
}, done);
19+
});
20+
21+
gulp.task('tdd', function (done) {
22+
gulp.watch(paths.scripts, ['lint']);
23+
24+
karma.start({
25+
configFile: paths.karmaConfig
26+
}, done);
27+
});
28+
29+
gulp.task('jshint', function () {
30+
return gulp
31+
.src(paths.scripts)
32+
.pipe(jshint())
33+
.pipe(jshint.reporter('jshint-stylish'))
34+
.pipe(jshint.reporter('fail'));
35+
});
36+
37+
gulp.task('default', ['jshint', 'test']);

Diff for: package.json

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "0.3.5",
44
"description": "This directive allows you to add a datetime-picker to your form elements.",
55
"author": "https://github.com/dalelotts/ng-bootstrap-datetimepicker/graphs/contributors",
6+
"bugs": {
7+
"url": "https://github.com/dalelotts/ng-bootstrap-datetimepicker/issues"
8+
},
69
"license": "MIT",
710
"homepage": "http://dalelotts.github.io/angular-bootstrap-datetimepicker",
811
"main": "src/js/datetimepicker.js",
@@ -15,6 +18,11 @@
1518
"grunt-contrib-jshint": "^0.10.0",
1619
"grunt-istanbul-coverage": "^0.1.0",
1720
"grunt-karma": "^0.9.0",
21+
"gulp": "^3.8.10",
22+
"gulp-jshint": "^1.9.0",
23+
"gulp-tap": "^0.1.3",
24+
"jshint-stylish": "^1.0.0",
25+
"karma": "^0.12.25",
1826
"karma-chrome-launcher": "^0.1.5",
1927
"karma-coverage": "^0.2.1",
2028
"karma-firefox-launcher": "^0.1.3",

Diff for: src/js/datetimepicker.js

+55-57
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('ui.bootstrap.datetimepicker', [])
2121
startView: 'day'
2222
})
2323
.directive('datetimepicker', ['$log', 'dateTimePickerConfig', function ($log, defaultConfig) {
24-
"use strict";
24+
'use strict';
2525

2626
function DateObject() {
2727

@@ -46,82 +46,80 @@ angular.module('ui.bootstrap.datetimepicker', [])
4646
for (var prop in configuration) {
4747
//noinspection JSUnfilteredForInLoop
4848
if (validOptions.indexOf(prop) < 0) {
49-
throw ("invalid option: " + prop);
49+
throw ('invalid option: ' + prop);
5050
}
5151
}
5252

5353
// Order of the elements in the validViews array is significant.
5454
var validViews = ['minute', 'hour', 'day', 'month', 'year'];
5555

5656
if (validViews.indexOf(configuration.startView) < 0) {
57-
throw ("invalid startView value: " + configuration.startView);
57+
throw ('invalid startView value: ' + configuration.startView);
5858
}
5959

6060
if (validViews.indexOf(configuration.minView) < 0) {
61-
throw ("invalid minView value: " + configuration.minView);
61+
throw ('invalid minView value: ' + configuration.minView);
6262
}
6363

6464
if (validViews.indexOf(configuration.minView) > validViews.indexOf(configuration.startView)) {
65-
throw ("startView must be greater than minView");
65+
throw ('startView must be greater than minView');
6666
}
6767

6868
if (!angular.isNumber(configuration.minuteStep)) {
69-
throw ("minuteStep must be numeric");
69+
throw ('minuteStep must be numeric');
7070
}
7171
if (configuration.minuteStep <= 0 || configuration.minuteStep >= 60) {
72-
throw ("minuteStep must be greater than zero and less than 60");
72+
throw ('minuteStep must be greater than zero and less than 60');
7373
}
7474
if (configuration.dropdownSelector !== null && !angular.isString(configuration.dropdownSelector)) {
75-
throw ("dropdownSelector must be a string");
75+
throw ('dropdownSelector must be a string');
7676
}
7777

78-
if (configuration.dropdownSelector != null) {
79-
/* istanbul ignore next */
80-
if ((typeof jQuery === 'undefined') || (typeof jQuery().dropdown !== 'function')) {
81-
$log.error("Please DO NOT specify the dropdownSelector option unless you are using jQuery AND Bootstrap.js. " +
82-
"Please include jQuery AND Bootstrap.js, or write code to close the dropdown in the on-set-time callback. \n\n" +
83-
"The dropdownSelector configuration option is being removed because it will not function properly.");
84-
delete configuration.dropdownSelector;
85-
}
78+
/* istanbul ignore next */
79+
if (configuration.dropdownSelector !== null && ((typeof jQuery === 'undefined') || (typeof jQuery().dropdown !== 'function'))) {
80+
$log.error('Please DO NOT specify the dropdownSelector option unless you are using jQuery AND Bootstrap.js. ' +
81+
'Please include jQuery AND Bootstrap.js, or write code to close the dropdown in the on-set-time callback. \n\n' +
82+
'The dropdownSelector configuration option is being removed because it will not function properly.');
83+
delete configuration.dropdownSelector;
8684
}
8785
};
8886

8987
return {
9088
restrict: 'E',
9189
require: 'ngModel',
92-
template: "<div class='datetimepicker table-responsive'>" +
93-
"<table class='table table-striped'>" +
94-
" <thead>" +
95-
" <tr>" +
96-
" <th class='left' data-ng-click='changeView(data.currentView, data.leftDate, $event)' data-ng-show='data.leftDate.selectable'><i class='glyphicon glyphicon-arrow-left'/></th>" +
97-
" <th class='switch' colspan='5' data-ng-show='data.previousViewDate.selectable' data-ng-click='changeView(data.previousView, data.previousViewDate, $event)'>{{ data.previousViewDate.display }}</th>" +
98-
" <th class='right' data-ng-click='changeView(data.currentView, data.rightDate, $event)' data-ng-show='data.rightDate.selectable'><i class='glyphicon glyphicon-arrow-right'/></th>" +
99-
" </tr>" +
100-
" <tr>" +
101-
" <th class='dow' data-ng-repeat='day in data.dayNames' >{{ day }}</th>" +
102-
" </tr>" +
103-
" </thead>" +
104-
" <tbody>" +
105-
" <tr data-ng-if='data.currentView !== \"day\"' >" +
106-
" <td colspan='7' >" +
107-
" <span class='{{ data.currentView }}' " +
108-
" data-ng-repeat='dateObject in data.dates' " +
109-
" data-ng-class='{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}' " +
110-
" data-ng-click=\"changeView(data.nextView, dateObject, $event)\">{{ dateObject.display }}</span> " +
111-
" </td>" +
112-
" </tr>" +
113-
" <tr data-ng-if='data.currentView === \"day\"' data-ng-repeat='week in data.weeks'>" +
114-
" <td data-ng-repeat='dateObject in week.dates' " +
115-
" data-ng-click='changeView(data.nextView, dateObject, $event)'" +
116-
" class='day' " +
117-
" data-ng-class='{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}' >{{ dateObject.display }}</td>" +
118-
" </tr>" +
119-
" </tbody>" +
120-
"</table></div>",
90+
template: '<div class="datetimepicker table-responsive">' +
91+
'<table class="table table-striped">' +
92+
' <thead>' +
93+
' <tr>' +
94+
' <th class="left" data-ng-click="changeView(data.currentView, data.leftDate, $event)" data-ng-show="data.leftDate.selectable"><i class="glyphicon glyphicon-arrow-left"/></th>' +
95+
' <th class="switch" colspan="5" data-ng-show="data.previousViewDate.selectable" data-ng-click="changeView(data.previousView, data.previousViewDate, $event)">{{ data.previousViewDate.display }}</th>' +
96+
' <th class="right" data-ng-click="changeView(data.currentView, data.rightDate, $event)" data-ng-show="data.rightDate.selectable"><i class="glyphicon glyphicon-arrow-right"/></th>' +
97+
' </tr>' +
98+
' <tr>' +
99+
' <th class="dow" data-ng-repeat="day in data.dayNames" >{{ day }}</th>' +
100+
' </tr>' +
101+
' </thead>' +
102+
' <tbody>' +
103+
' <tr data-ng-if="data.currentView !== \'day\'" >' +
104+
' <td colspan="7" >' +
105+
' <span class="{{ data.currentView }}" ' +
106+
' data-ng-repeat="dateObject in data.dates" ' +
107+
' data-ng-class="{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}" ' +
108+
' data-ng-click="changeView(data.nextView, dateObject, $event)">{{ dateObject.display }}</span> ' +
109+
' </td>' +
110+
' </tr>' +
111+
' <tr data-ng-if="data.currentView === \'day\'" data-ng-repeat="week in data.weeks">' +
112+
' <td data-ng-repeat="dateObject in week.dates" ' +
113+
' data-ng-click="changeView(data.nextView, dateObject, $event)"' +
114+
' class="day" ' +
115+
' data-ng-class="{active: dateObject.active, past: dateObject.past, future: dateObject.future, disabled: !dateObject.selectable}" >{{ dateObject.display }}</td>' +
116+
' </tr>' +
117+
' </tbody>' +
118+
'</table></div>',
121119
scope: {
122-
ngModel: "=",
123-
onSetTime: "&",
124-
beforeRender: "&"
120+
ngModel: '=',
121+
onSetTime: '&',
122+
beforeRender: '&'
125123
},
126124
replace: true,
127125
link: function (scope, element, attrs, ngModelController) {
@@ -163,7 +161,7 @@ angular.module('ui.bootstrap.datetimepicker', [])
163161
'dates': []
164162
};
165163

166-
for (var i = 0; i < 12; i++) {
164+
for (var i = 0; i < 12; i += 1) {
167165
var yearMoment = moment.utc(startDate).add(i, 'years');
168166
var dateValue = {
169167
'dateValue': yearMoment.valueOf(),
@@ -198,7 +196,7 @@ angular.module('ui.bootstrap.datetimepicker', [])
198196
'dates': []
199197
};
200198

201-
for (var i = 0; i < 12; i++) {
199+
for (var i = 0; i < 12; i += 1) {
202200
var monthMoment = moment.utc(startDate).add(i, 'months');
203201
var dateValue = {
204202
'dateValue': monthMoment.valueOf(),
@@ -238,13 +236,13 @@ angular.module('ui.bootstrap.datetimepicker', [])
238236
};
239237

240238

241-
for (var dayNumber = 0; dayNumber < 7; dayNumber++) {
239+
for (var dayNumber = 0; dayNumber < 7; dayNumber += 1) {
242240
result.dayNames.push(moment.utc().weekday(dayNumber).format('dd'));
243241
}
244242

245-
for (var i = 0; i < 6; i++) {
243+
for (var i = 0; i < 6; i += 1) {
246244
var week = {dates: []};
247-
for (var j = 0; j < 7; j++) {
245+
for (var j = 0; j < 7; j += 1) {
248246
var monthMoment = moment.utc(startDate).add((i * 7) + j, 'days');
249247
var dateValue = {
250248
'dateValue': monthMoment.valueOf(),
@@ -280,7 +278,7 @@ angular.module('ui.bootstrap.datetimepicker', [])
280278
'dates': []
281279
};
282280

283-
for (var i = 0; i < 24; i++) {
281+
for (var i = 0; i < 24; i += 1) {
284282
var hourMoment = moment.utc(selectedDate).add(i, 'hours');
285283
var dateValue = {
286284
'dateValue': hourMoment.valueOf(),
@@ -314,7 +312,7 @@ angular.module('ui.bootstrap.datetimepicker', [])
314312

315313
var limit = 60 / configuration.minuteStep;
316314

317-
for (var i = 0; i < limit; i++) {
315+
for (var i = 0; i < limit; i += 1) {
318316
var hourMoment = moment.utc(selectedDate).add(i * configuration.minuteStep, 'minute');
319317
var dateValue = {
320318
'dateValue': hourMoment.valueOf(),
@@ -361,9 +359,9 @@ angular.module('ui.bootstrap.datetimepicker', [])
361359

362360
var weekDates = [];
363361
if (result.weeks) {
364-
for (var i = 0; i < result.weeks.length; i++) {
362+
for (var i = 0; i < result.weeks.length; i += 1) {
365363
var week = result.weeks[i];
366-
for (var j = 0; j < week.dates.length; j++) {
364+
for (var j = 0; j < week.dates.length; j += 1) {
367365
var weekDate = week.dates[j];
368366
weekDates.push(weekDate);
369367
}

0 commit comments

Comments
 (0)