Skip to content

Commit 85c9611

Browse files
committedOct 22, 2014
Updated build process.
1 parent 00030c8 commit 85c9611

13 files changed

+180
-49
lines changed
 

‎.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
node_modules
1+
.tmp/
2+
node_modules/
3+
bower_components/

‎Gruntfile.js

+41-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,55 @@ module.exports = function (grunt) {
22
require('load-grunt-tasks')(grunt);
33

44
grunt.initConfig({
5+
pkg: grunt.file.readJSON('package.json'),
56
uglify: {
67
dist: {
78
files: {
8-
'dist/placeholders.min.js': ['src/placeholders.js']
9+
'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
910
}
1011
}
12+
},
13+
14+
concat: {
15+
dist: {
16+
src: ['src/<%= pkg.name %>.js', 'src/directive.js', 'src/service.js'],
17+
dest: 'dist/<%= pkg.name %>.js',
18+
options: {
19+
banner: grunt.file.read('src/intro').toString(),
20+
footer: grunt.file.read('src/outro').toString()
21+
}
22+
}
23+
},
24+
25+
usebanner: {
26+
dist: {
27+
options: {
28+
banner: '/*\n' +
29+
'\t<%= pkg.name %> v<%= pkg.version %>\n' +
30+
'\t<%= pkg.homepage %>\n\n' +
31+
'\tCopyright (c) <%= grunt.template.today(\'yyyy\') %> <%= pkg.author.name %> <<%= pkg.author.email %>>\n\n' +
32+
'\tLicense: MIT (<%= pkg.homepage %>/blob/master/LICENSE)\n*/\n\n'
33+
},
34+
files: {
35+
src: ['dist/**/*.js']
36+
}
37+
}
38+
},
39+
40+
karma: {
41+
unit: {
42+
configFile: 'test/karma.conf.js'
43+
}
1144
}
1245
});
1346

1447
grunt.registerTask('build', [
15-
'uglify'
48+
'concat:dist',
49+
'uglify:dist',
50+
'usebanner:dist'
51+
]);
52+
53+
grunt.registerTask('test', [
54+
'karma'
1655
]);
1756
};

‎LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

‎bower.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "angular-input-placeholders",
3+
"version": "0.0.2",
34
"authors": [
45
"William Boman <william@redwill.se>"
56
],

‎src/placeholder.js renamed to ‎dist/angular-input-placeholders.js

+66-8
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,96 @@
1-
'use strict';
1+
/*
2+
angular-input-placeholders v0.0.2
3+
https://github.com/williamboman/angular-placeholders
4+
5+
Copyright (c) 2014 William Boman <william@redwill.se>
6+
7+
License: MIT (https://github.com/williamboman/angular-placeholders/blob/master/LICENSE)
8+
*/
9+
10+
11+
(function (angular) {
12+
'use strict';
13+
angular.module('wb.inputHinter', [
14+
'wb.inputHinter.service',
15+
'wb.inputHinter.directive'
16+
]);
17+
18+
angular
19+
.module('wb.inputHinter.directive', [])
20+
21+
.directive('inputHinter', ['inputHinter',
22+
function (inputHinter) {
23+
return {
24+
restrict: 'A',
25+
link: function (scope, element, attr) {
26+
var userConfig = {
27+
waitBeforeDeleteMs: attr.waitBeforeDeleteMs,
28+
waitInBetweenMs: attr.waitInBetweenMs,
29+
writeSpeedMs: attr.writeSpeedMs,
30+
deleteSpeedMs: attr.deleteSpeedMs,
31+
delimiter: attr.delimiter
32+
};
33+
34+
// Unset non-existing config values.
35+
angular.forEach(userConfig, function (key, val) {
36+
if( typeof val === 'undefined' ) {
37+
delete userConfig[key];
38+
}
39+
});
40+
41+
var ticker = new inputHinter(userConfig);
42+
43+
ticker.placeholders = attr.inputHinter.split('|');
44+
45+
ticker.onTick = function (newPlaceholderText) {
46+
element.attr('placeholder', newPlaceholderText);
47+
};
48+
49+
scope.Ticker.init();
50+
}
51+
};
52+
}
53+
]);
54+
55+
angular
56+
.module('wb.inputHinter.service', [])
257

3-
angular.module('wb.inputPholders')
4-
.provider('inputPholders', function () {
58+
.provider('inputHinter', function () {
559
var config = this.config = {
660
waitBeforeDeleteMs: 2000,
761
waitInBetweenMs: 300,
862
writeSpeedMs: 100,
9-
deleteSpeedMs: 60
63+
deleteSpeedMs: 60,
64+
delimiter: '|'
1065
};
1166

1267
this.$get = ['$timeout',
1368
function ($timeout) {
1469

15-
function Ticker() {
70+
function Ticker(userConfig) {
71+
userConfig = userConfig || {};
1672
this.currentPlaceholderText = '';
1773
this.currentPlaceholdersIndex = 0;
1874
this.currentPlaceholderIndex = 0;
1975
this.isDeleting = false;
2076
this.timeout = undefined;
2177

22-
this.config = config;
78+
this.config = angular.copy(config);
79+
angular.extend(this.config, userConfig);
2380
}
2481

2582
Ticker.prototype = {
2683
init: function () {
2784
if( !this.placeholders ) {
28-
throw new TypeError('[wb.inputPholder] This instance of Ticker is missing Ticker.placeholders property.');
85+
throw new TypeError('[wb.inputHinter] This instance of Ticker is missing Ticker.placeholders property.');
2986
}
3087

3188
if( this.userConfig ) {
3289
angular.extend(this.config, this.userConfig);
3390
}
3491

3592
if( !this.onTick || typeof this.onTick !== 'function' ) {
36-
throw new TypeError('[wb.inputPholder] This instance of Ticker is missing a valid Ticker.onTick callback function.');
93+
throw new TypeError('[wb.inputHinter] This instance of Ticker is missing a valid Ticker.onTick callback function.');
3794
}
3895

3996
this.tick();
@@ -110,3 +167,4 @@ angular.module('wb.inputPholders')
110167
}
111168
];
112169
});
170+
})(window.angular);

‎dist/angular-input-placeholders.min.js

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/placeholders.min.js

-1
This file was deleted.

‎package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
"email": "william@redwill.se",
88
"url": "http://william.redwill.se"
99
},
10-
"dependencies": {
11-
"angular": "~1.2.6"
12-
},
1310
"devDependencies": {
1411
"grunt": "^0.4.5",
12+
"grunt-banner": "^0.2.3",
13+
"grunt-contrib-concat": "^0.5.0",
1514
"grunt-contrib-uglify": "^0.5.0",
15+
"grunt-karma": "^0.8.3",
16+
"karma": "^0.12.16",
17+
"karma-chrome-launcher": "^0.1.4",
18+
"karma-jasmine": "^0.1.5",
1619
"load-grunt-tasks": "^0.5.0"
1720
},
1821
"keywords": [
@@ -25,5 +28,5 @@
2528
"type"
2629
],
2730
"license": "MIT",
28-
"homepage": "https://github.com/williamboman/angular-placeholders",
31+
"homepage": "https://github.com/williamboman/angular-placeholders"
2932
}

‎src/angular-input-placeholders.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
31
angular.module('wb.inputHinter', [
42
'wb.inputHinter.service',
5-
'wb.inputHinter.directive'
3+
'wb.inputHinter.directive'
64
]);

‎src/directive.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
'use strict';
2-
31
angular
42
.module('wb.inputHinter.directive', [])
53

6-
.directive('inputHinter', function (inputHinter) {
7-
return {
8-
restrict: 'A',
9-
link: function (scope, element, attr) {
10-
var userConfig = {
11-
waitBeforeDeleteMs: attr.waitBeforeDeleteMs,
12-
waitInBetweenMs: attr.waitInBetweenMs,
13-
writeSpeedMs: attr.writeSpeedMs,
14-
deleteSpeedMs: attr.deleteSpeedMs,
15-
delimiter: attr.delimiter
16-
};
4+
.directive('inputHinter', ['inputHinter',
5+
function (inputHinter) {
6+
return {
7+
restrict: 'A',
8+
link: function (scope, element, attr) {
9+
var userConfig = {
10+
waitBeforeDeleteMs: attr.waitBeforeDeleteMs,
11+
waitInBetweenMs: attr.waitInBetweenMs,
12+
writeSpeedMs: attr.writeSpeedMs,
13+
deleteSpeedMs: attr.deleteSpeedMs,
14+
delimiter: attr.delimiter
15+
};
1716

18-
// Unset non-existing config values.
19-
angular.forEach(userConfig, function (key, val) {
20-
if( typeof val === 'undefined' ) {
21-
delete userConfig[key];
22-
}
23-
});
17+
// Unset non-existing config values.
18+
angular.forEach(userConfig, function (key, val) {
19+
if( typeof val === 'undefined' ) {
20+
delete userConfig[key];
21+
}
22+
});
2423

25-
var ticker = new inputHinter(userConfig);
24+
var ticker = new inputHinter(userConfig);
2625

27-
ticker.placeholders = attr.inputHinter.split('|');
26+
ticker.placeholders = attr.inputHinter.split('|');
2827

29-
ticker.onTick = function (newPlaceholderText) {
30-
element.attr('placeholder', newPlaceholderText);
31-
};
28+
ticker.onTick = function (newPlaceholderText) {
29+
element.attr('placeholder', newPlaceholderText);
30+
};
3231

33-
scope.Ticker.init();
34-
}
35-
};
36-
});
32+
scope.Ticker.init();
33+
}
34+
};
35+
}
36+
]);

‎src/intro

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(function (angular) {
2+
'use strict';

‎src/outro

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
})(window.angular);

‎src/service.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
angular
42
.module('wb.inputHinter.service', [])
53

0 commit comments

Comments
 (0)
Please sign in to comment.