1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('jquery-ui-timepicker-addon.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
//'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.modified %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
clean: {
files: ['dist']
},
copy: {
dist: {
files: [
//{ src: 'src/index.html', dest: 'dist/index.html' },
{ src: 'src/<%= pkg.name %>.css', dest: 'dist/<%= pkg.name %>.css' },
{ src: 'src/jquery-ui-sliderAccess.js', dest: 'dist/jquery-ui-sliderAccess.js' },
{ src: 'src/i18n/jquery-ui-timepicker-*.js', dest: 'dist/i18n/', expand:true, flatten: true }
]
}
},
concat: {
dist: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
src: ['src/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
},
docs: {
src: [
'src/docs/header.html',
'src/docs/intro.html',
'src/docs/options.html',
'src/docs/formatting.html',
'src/docs/i18n.html',
'src/docs/examples.html',
'src/docs/footer.html'
],
dest: 'dist/index.html'
},
i18n: {
options: {
//stripBanners: true,
banner: '<%=banner %>\n(function($){\n\n',
footer: '\n})(jQuery);\n',
process: function(src, filepath){
return '// source: '+ filepath + '\n' +
src.replace(/\(function\s*\(\$\)\s*\{/g, '')
.replace(/\}\)\(jQuery\)\;/g, '')
.replace(/\$\.timepicker\.setDefaults\(\$\.timepicker\.regional\[[a-z\-\'\"]+\]\)\;/gi, '')
.trim() +'\n';
}
},
src: [ 'src/i18n/jquery-ui-timepicker-*.js' ],
dest: 'dist/i18n/<%=pkg.name %>-i18n.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
},
i18n: {
src: 'dist/i18n/<%=pkg.name %>-i18n.js',
dest: 'dist/i18n/<%=pkg.name %>-i18n.min.js'
}
},
cssmin: {
options: {
banner: '<%= banner %>'
},
dist: {
src: 'dist/<%= pkg.name %>.css',
dest: 'dist/<%= pkg.name %>.min.css'
}
},
replace: {
dist: {
options: {
variables: {
version: '<%= pkg.version %>',
timestamp: '<%= pkg.modified %>'
},
prefix: '@@'
},
files: [
{ src: 'dist/<%= pkg.name %>.js', dest: 'dist/<%= pkg.name %>.js' },
{ src: 'dist/<%= pkg.name %>.css', dest: 'dist/<%= pkg.name %>.css' },
{ src: 'dist/index.html', dest: 'dist/index.html' }
]
}
},
jasmine: {
src: 'src/<%= pkg.name %>.js',
options: {
specs: 'test/*_spec.js',
vendor: [
'http://code.jquery.com/jquery-1.11.1.min.js',
'http://code.jquery.com/ui/1.11.1/jquery-ui.min.js',
'http://github.com/searls/jasmine-fixture/releases/1.0.5/1737/jasmine-fixture.js'
]
}
},
jshint: {
gruntfile: {
options: {
jshintrc: '.jshintrc'
},
src: 'Gruntfile.js'
},
src: {
options: {
jshintrc: 'src/.jshintrc'
},
src: ['src/**/*.js']
},
test: {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['test/**/*.js']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
src: {
files: 'src/**',//'<%= jshint.src.src %>',
tasks: ['jshint:src', 'jasmine', 'clean', 'copy', 'concat', 'replace', 'uglify', 'cssmin']
//tasks: ['jshint:src', 'jasmine']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'jasmine']
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('default', ['clean', 'copy', 'concat', 'replace', 'uglify', 'cssmin']);
// Test task.
grunt.registerTask('test', ['jshint', 'jasmine']);
};
|