Skip to content

Commit ba42b54

Browse files
author
Null McNull
committed
version 0.0.1
1 parent 7e43f2d commit ba42b54

File tree

6 files changed

+148
-51
lines changed

6 files changed

+148
-51
lines changed

bower.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
{
22
"name": "angular-block-ui",
3-
"version": "0.0.0",
3+
"version": "0.0.1",
44
"authors": [
55
"Null McNull <[email protected]>"
66
],
7-
"description": "AngularJS Block UI module",
7+
"description": "A simple AngularJS module that allows you to block user interaction on AJAX requests. Blocking is done automatically for each http request and/or manually via an injectable service.",
88
"license": "MIT",
9+
"main" : "package/**/*",
910
"ignore": [
1011
"**/.*",
12+
"*.sublime-project",
13+
"gruntfile.js",
1114
"node_modules",
12-
"bower_components",
13-
"test",
14-
"tests"
15+
"vendor",
16+
"dist",
17+
"grunt",
18+
"karma",
19+
"server",
20+
"src",
21+
"tmp"
1522
],
1623
"dependencies": {
1724
"angular": "~1.2.4",
25+
},
26+
"devDependencies": {
1827
"bootstrap-css": "2.3.2",
1928
"angular-route": "~1.2.4",
2029
"angular-resource": "~1.2.4",
21-
"lodash": "~2.4.1"
22-
},
23-
"devDependencies": {
30+
"lodash": "~2.4.1",
2431
"angular-mocks": "~1.2.4"
2532
}
2633
}

grunt/grunt-common.js

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,31 @@ module.exports = function(grunt) {
1919
projectFiles.addArea(taskname, areaname);
2020
},
2121
registerTasks: function() {
22-
grunt.log.writeln('Registering tasks ...');
23-
grunt.loadNpmTasks('grunt-contrib-clean');
24-
grunt.loadNpmTasks('grunt-ejs-render');
25-
grunt.loadNpmTasks('grunt-karma');
26-
grunt.registerTask('ejs', [ 'clean:render', 'render:index', 'render:karmaConf' ]);
27-
grunt.registerTask('test', [ 'render:karmaConf', 'karma:unit' ]);
22+
grunt.log.writeln('Registering tasks ...');
23+
grunt.loadNpmTasks('grunt-contrib-clean');
24+
grunt.loadNpmTasks('grunt-ejs-render');
25+
grunt.loadNpmTasks('grunt-karma');
26+
grunt.registerTask('ejs', ['clean:render', 'render:index', 'render:karmaConf']);
27+
grunt.registerTask('test-single', ['render:karmaConf', 'karma:single']);
28+
grunt.registerTask('test', ['build', 'render:karmaConf', 'karma:unit']);
29+
},
30+
expandGlobs: function(globs, cwd) {
31+
32+
// Workaround for the concat grunt task in combination with cwd.
33+
34+
// Shama made me do this :(
35+
// https://github.com/gruntjs/grunt-contrib-concat/issues/31
36+
37+
var result = grunt.file.expand({
38+
cwd: cwd
39+
}, globs).map(function(glob) {
40+
return cwd + '/' + glob;
41+
});
42+
43+
return result;
44+
},
45+
getProjectFiles: function() {
46+
return projectFiles;
2847
},
2948
getConfig: function() {
3049

@@ -42,22 +61,22 @@ module.exports = function(grunt) {
4261

4362
sections = sections || 'vendorAreas';
4463

45-
if(_.isString(sections)) {
64+
if (_.isString(sections)) {
4665
sections = sectionsDefaults[sections];
4766
}
4867

49-
if(!_.isArray(sections)) {
68+
if (!_.isArray(sections)) {
5069
throw Error('Argument sections should either be an explicit array of section names or one of the following string values: "vendor", "vendorAreas" or "areas"');
5170
}
5271

5372
cwd = cwd || 'dist';
5473

55-
if(prefix) {
56-
if(_.isBoolean(prefix)) {
74+
if (prefix) {
75+
if (_.isBoolean(prefix)) {
5776
prefix = cwd;
5877
}
5978

60-
if(prefix[prefix.length-1] !== '/') prefix += '/';
79+
if (prefix[prefix.length - 1] !== '/') prefix += '/';
6180
}
6281

6382
var globs = [];
@@ -66,10 +85,14 @@ module.exports = function(grunt) {
6685
globs = globs.concat(projectFiles[section][ext]);
6786
});
6887

69-
var results = grunt.file.expand({ cwd: cwd }, globs);
88+
var results = grunt.file.expand({
89+
cwd: cwd
90+
}, globs);
7091

71-
if(prefix) {
72-
results = _.map(results, function(val) { return prefix + val; });
92+
if (prefix) {
93+
results = _.map(results, function(val) {
94+
return prefix + val;
95+
});
7396
}
7497

7598
return results;
@@ -78,40 +101,57 @@ module.exports = function(grunt) {
78101
var gruntConfig = {
79102
files: projectFiles,
80103
clean: {
81-
render: [ 'dist/index.html', 'karma/karma.conf.js' ],
82-
tmp: [ 'tmp' ],
83-
vendor: [ 'dist/vendor' ],
104+
render: ['dist/index.html', 'karma/karma.conf.js'],
105+
tmp: ['tmp'],
106+
vendor: ['dist/vendor'],
84107
postBuild: {
85-
src: [ 'dist/**/*' ],
86-
filter: function (filepath) {
108+
src: ['dist/**/*'],
109+
filter: function(filepath) {
87110
// Removes only empty folders
88111
return grunt.file.isDir(filepath) && fs.readdirSync(filepath).length === 0;
89112
}
90113
}
91114
},
92115
render: {
93116
index: {
94-
options: { helpers: { getIncludes: getIncludes, target: target } },
95-
files: { 'dist/index.html': [ 'src/index.ejs' ] }
117+
options: {
118+
helpers: {
119+
getIncludes: getIncludes,
120+
target: target
121+
}
122+
},
123+
files: {
124+
'dist/index.html': ['src/index.ejs']
125+
}
96126
},
97127
karmaConf: {
98-
options: { helpers: { getIncludes: getIncludes, target: target } },
99-
files: { 'karma/karma.conf.js': [ 'karma/karma.conf.ejs' ] }
128+
options: {
129+
helpers: {
130+
getIncludes: getIncludes,
131+
target: target
132+
}
133+
},
134+
files: {
135+
'karma/karma.conf.js': ['karma/karma.conf.ejs']
136+
}
100137
}
101138
},
102139
karma: {
103140
unit: {
104141
configFile: 'karma/karma.conf.js'
105-
}
142+
},
143+
single: {
144+
singleRun: true,
145+
configFile: 'karma/karma.conf.js'
146+
},
106147
}
107148
};
108149

109150
_.forEach(areas, function(area) {
110-
gruntConfig.clean[area.taskname] = [ 'dist/' + area.areaname ];
151+
gruntConfig.clean[area.taskname] = ['dist/' + area.areaname];
111152
});
112153

113154
return gruntConfig;
114155
}
115156
};
116157
};
117-

grunt/grunt-debug.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ module.exports = function (grunt) {
1515
dest: 'dist/'
1616
}
1717
},
18-
html2js: {}
18+
html2js: {},
19+
concat: {}
1920
};
2021

22+
var projectFiles = gruntCommon.getProjectFiles();
23+
2124
var areas = [];
2225

2326
return {
@@ -50,14 +53,36 @@ module.exports = function (grunt) {
5053
]
5154
};
5255

56+
///////////////////////////////////////
57+
// Package tasks
58+
59+
var areaJsGlobs = projectFiles[taskname].js;
60+
61+
gruntConfig.concat[taskname + 'Js'] = {
62+
src: gruntCommon.expandGlobs(areaJsGlobs, 'src').concat(['<%= html2js.' + taskname + '.dest %>']),
63+
dest: 'package/' + areaname + '/' + areaname + '.js'
64+
};
65+
66+
var areaCssGlobs = projectFiles[taskname].css;
67+
68+
gruntConfig.concat[taskname + 'Css'] = {
69+
src: gruntCommon.expandGlobs(areaCssGlobs, 'src'),
70+
dest: 'package/' + areaname + '/' + areaname + '.css'
71+
};
72+
73+
grunt.registerTask('package:' + taskname, ['build', 'test-single', 'concat:' + taskname + 'Css', 'concat:' + taskname + 'Js']);
74+
75+
///////////////////////////////////////
76+
5377
return this;
5478
},
5579
registerTasks: function() {
5680

5781
gruntCommon.registerTasks();
5882

5983
grunt.loadNpmTasks('grunt-contrib-copy');
60-
grunt.loadNpmTasks('grunt-html2js');
84+
grunt.loadNpmTasks('grunt-contrib-concat');
85+
grunt.loadNpmTasks('grunt-html2js');
6186

6287
grunt.registerTask('vendor', [ 'clean:vendor', 'copy:vendor' ]);
6388

grunt/grunt-release.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ module.exports = function (grunt) {
6060
]
6161
};
6262

63+
///////////////////////////////////////
64+
// Package tasks
65+
66+
gruntConfig.copy[taskname + 'Package'] = {
67+
files: [
68+
{ expand: true, flatten: true, src: ['dist/' + areaname + '/**/*'], dest: 'package/' + areaname }
69+
]
70+
};
71+
72+
grunt.registerTask('package:' + taskname, ['build', 'test-single', 'copy:' + taskname + 'Package']);
73+
74+
///////////////////////////////////////
75+
6376
return this;
6477
},
6578

@@ -78,12 +91,18 @@ module.exports = function (grunt) {
7891
grunt.registerTask(area, [ 'clean:' + area, 'html2js:' + area, 'ngmin:' + area, 'uglify:' + area, 'cssmin:' + area, 'copy:' + area ]);
7992
});
8093

81-
var buildTasks = [ 'clean:tmp', 'vendor', /* areas */ 'ejs', 'clean:postBuild', 'test' ];
94+
var buildTasks = [ 'clean:tmp', 'vendor', /* areas */ 'ejs', 'clean:postBuild'];
8295
var args = [2, 0].concat(areas);
8396
Array.prototype.splice.apply(buildTasks, args);
8497

8598
grunt.registerTask('build', buildTasks);
8699
grunt.registerTask('default', 'build');
100+
101+
// var packageTasks = _.map(areas, function(area) {
102+
// return 'copy:' + area + 'Package';
103+
// });
104+
105+
// grunt.registerTask('package', ['build', 'test-single'].concat(packageTasks));
87106
},
88107

89108
getConfig: function() {

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "angular-init",
3-
"version": "0.0.0",
4-
"description": "AngularJS boilerplate project",
2+
"name": "angular-block-ui",
3+
"version": "0.0.1",
4+
"description": "A simple AngularJS module that allows you to block user interaction on AJAX requests. Blocking is done automatically for each http request and/or manually via an injectable service.",
55
"main": "grunt",
66
"scripts": {
77
"test": "grunt test"
88
},
99
"keywords": [
1010
"angular",
1111
"angularjs",
12-
"boilerplate"
12+
"blockUI"
1313
],
1414
"author": "Null McNull",
1515
"license": "BSD-2-Clause",

src/app/main/home.tmpl.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ <h2 class="visible-phone">
1919

2020
<div class="span6">
2121

22+
<h1>angular-block-ui</h1>
23+
24+
<p>A simple AngularJS module that allows you to block user interaction on AJAX requests. Blocking is done automatically for each http request and/or manually via an injectable service.</p>
25+
2226
<h4>Dependencies</h4>
2327

2428
<p>Besides AngularJS (~1.2.4), none. </p>
2529

2630
<h4>Usage</h4>
2731

28-
<p>The blockUI module exposes a service by the same name. Access to the service is gained by injecting it into your controller or directive:</p>
32+
<p>By default the module will block the user interface on each pending request made from the browser. This behavior can be modified in the configuration.</p>
33+
34+
<p>It&#8217;s also possible to do the blocking manually. The blockUI module exposes a service by the same name. Access to the service is gained by injecting it into your controller or directive:</p>
2935

3036
<pre><code>angular.module('myApp').controller('MyController', function($scope, blockUI) {
3137
// A function called from user interface, which performs an async operation.
@@ -109,10 +115,13 @@ <h4>message</h4>
109115

110116
<h4>delay</h4>
111117

112-
<p>Specifies the amount in milliseconds before the block is visible to the user. By delaying a visible block your application will appear more responsive. The default value is <em>500</em>.</p>
118+
<p>Specifies the amount in milliseconds before the block is visible to the user. By delaying a visible block your application will appear more responsive. The default value is <em>250</em>.</p>
113119

114-
<pre><code>// Change the default delay to 100ms before the blocking is visible
120+
<pre><code>// Change the default delay to 100ms before the blocking is visible ...
115121
blockUIConfigProvider.delay(100);
122+
123+
// ... or completely remove the delay
124+
blockUIConfigProvider.delay(1);
116125
</code></pre>
117126

118127
<h4>template</h4>
@@ -131,12 +140,12 @@ <h4>templateUrl</h4>
131140
blockUIConfigProvider.templateUrl('my-templates/block-ui-overlay.html');
132141
</code></pre>
133142

134-
<h4>onLocationChange</h4>
143+
<h4>autoBlock</h4>
135144

136-
<p>By default the BlockUI module will start a block whenever a <em>$locationChangeStart</em> event is fired. You can set this value to <em>false</em> if you don&#8217;t want this behaviour.</p>
145+
<p>By default the BlockUI module will start a block whenever the Angular <em>$http</em> service has an pending request. If you don&#8217;t want this behaviour and want to do all the blocking manually you can change this value to <em>false</em>.</p>
137146

138-
<pre><code>// Disable blocking on location change
139-
blockUIConfigProvider.onLocationChange(false);
147+
<pre><code>// Disable automatically blocking of the user interface
148+
blockUIConfigProvider.autoBlock(false);
140149
</code></pre>
141150

142151
<h4>resetOnException</h4>
@@ -147,7 +156,4 @@ <h4>resetOnException</h4>
147156
blockUIConfigProvider.resetOnException(false);
148157
</code></pre>
149158

150-
151-
<!-- </div> -->
152-
153159
</div>

0 commit comments

Comments
 (0)