Skip to content

Commit d2dffa1

Browse files
author
Null McNull
committed
documentation/examples update
pre-bootstrap update
1 parent fbbda80 commit d2dffa1

File tree

14 files changed

+1076
-192
lines changed

14 files changed

+1076
-192
lines changed

grunt/project-files-debug.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ var files = {
2222
],
2323
other: [
2424
areaname + '/**/*.png',
25-
areaname + '/**/*.jpg'
25+
areaname + '/**/*.jpg',
26+
areaname + '/**/*.html',
27+
'!' +areaname + '/**/*.tmpl.html',
28+
areaname + '/**/*.json'
2629
],
2730
html2js: [
2831
areaname + '/templates-' + areaname + '.js'

grunt/project-files-release.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ var files = {
2626
],
2727
other: [
2828
areaname + '/**/*.png',
29-
areaname + '/**/*.jpg'
29+
areaname + '/**/*.jpg',
30+
areaname + '/**/*.html',
31+
'!' +areaname + '/**/*.tmpl.html',
32+
areaname + '/**/*.json'
3033
],
3134
html2js: [
3235
areaname + '/templates-' + areaname + '.js'

gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = function(grunt) {
77

88
gruntTarget.addArea('angularBlockUI', 'angular-block-ui')
99
.addArea('angularShowdown', 'angular-showdown')
10+
.addArea('angularDelay', 'angular-delay')
1011
.addArea('app')
1112
.registerTasks();
1213

server/lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ module.exports = {
77
distFolder: argv.root || '../dist',
88
listenPort: argv.port || 1337,
99
dataFolder: argv.data || 'data',
10-
delay: 500
10+
delay: 0
1111
}
1212
};

src/angular-delay/angular-delay.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
angular.module('delay', []);
2+
3+
angular.module('delay').constant('delayConfig', {
4+
enabled: true, // Enable or disable the delay
5+
timeout: {
6+
min: 200, // Minimum delay
7+
max: 1500 // Maximum delay
8+
},
9+
excludes: [] // Array of RegExp of urls to exclude
10+
});
11+
12+
angular.module('delay').factory('delayHttpInterceptor', function($q, $templateCache, $timeout, delayConfig) {
13+
14+
function includeRequest(config) {
15+
if (delayConfig.enabled && $templateCache.get(config.url) === undefined) {
16+
17+
var patterns = delayConfig.excludes;
18+
var i = patterns.length;
19+
20+
while (i--) {
21+
if (patterns[i].test(config.url)) {
22+
return false;
23+
}
24+
};
25+
26+
return true;
27+
}
28+
}
29+
30+
var t1 = delayConfig.timeout.min;
31+
var t2 = delayConfig.timeout.max - t1;
32+
33+
return {
34+
request: function(config) {
35+
36+
// Don't delay cached requests
37+
38+
if (!includeRequest(config)) {
39+
return config;
40+
}
41+
42+
var d = $q.defer();
43+
44+
var delay = Math.floor(Math.random() * t2) + t1;
45+
46+
$timeout(function() {
47+
d.resolve(config);
48+
}, delay);
49+
50+
return d.promise;
51+
}
52+
};
53+
});
54+
55+
angular.module('delay').config(function($httpProvider) {
56+
$httpProvider.interceptors.push('delayHttpInterceptor');
57+
});

src/app/app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
angular.module('myApp', ['ngRoute', 'ngResource', 'templates-app', 'blockUI', 'showdown'], null).value('navItems', [{
1+
angular.module('myApp', ['ngRoute', 'ngResource', 'templates-app', 'blockUI', 'showdown', 'delay'], null).value('navItems', [{
22
text: 'Home',
33
url: '#/'
44
}, {
@@ -27,7 +27,9 @@ angular.module('myApp', ['ngRoute', 'ngResource', 'templates-app', 'blockUI', 's
2727
redirectTo: '/'
2828
});
2929

30-
}).config(function(blockUIConfigProvider) {
30+
}).config(function(blockUIConfigProvider, delayConfig) {
31+
32+
delayConfig.excludes.push(/.*\.md/i);
3133
// blockUIConfigProvider.requestFilter(function(config) {
3234
// if(config.url.match(/^\/api\/quote($|\/).*/)) {
3335
// return false;

0 commit comments

Comments
 (0)