Skip to content

Commit 83e199e

Browse files
author
Philipp Alferov
committed
Use browserify to build docs scripts
1 parent 924e9e0 commit 83e199e

File tree

4 files changed

+32
-34
lines changed

4 files changed

+32
-34
lines changed

docs/assets/js/custom.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
(function() {
1+
var angular = require('angular');
2+
var fileSaver = require('../../../src/file-saver');
3+
window.saveAs = require('browser-filesaver');
24

3-
angular
4-
.module('ngFileSaver', ['fileSaver'])
5-
.controller('DownloadText', DownloadText);
5+
angular
6+
.module('ngFileSaver', ['fileSaver'])
7+
.controller('DownloadText', ['$scope', 'SaveAs', DownloadText]);
8+
console.log(angular);
9+
function DownloadText($scope, SaveAs) {
10+
var vm = this;
611

7-
function DownloadText($scope, SaveAs) {
8-
var vm = this;
12+
vm.val = {
13+
text: 'Hey ho lets go!'
14+
};
915

10-
vm.val = {
11-
text: 'Hey ho lets go!'
12-
};
13-
14-
vm.download = function(text) {
15-
16-
var options = {
17-
type: "text/plain;charset=utf-8"
18-
};
19-
20-
SaveAs.download([text], 'textfile.txt', options);
16+
vm.download = function(text) {
2117

18+
var options = {
19+
type: "text/plain;charset=utf-8"
2220
};
23-
}
2421

25-
})();
22+
SaveAs.download([text], 'textfile.txt', options);
23+
24+
};
25+
}

docs/index.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
<meta charset="UTF-8">
66
<title>Angular File Saver - an AngularJS service that provides cross-browser compatibility of the HTML5 saveAs()</title>
77
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
8+
<link rel="stylesheet" type="text/css" href="assets/stylesheets/normalize.css" media="screen">
99
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
10-
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
11-
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
12-
<script src="js/vendors/angular/angular.js"></script>
13-
<script src="js/vendors/blob-polyfill/Blob.js"></script>
14-
<script src="js/vendors/file-saver.js/FileSaver.js"></script>
15-
<script src="js/vendors/angular-file-saver/src/file-saver.js"></script>
16-
<script src="js/custom.js"></script>
10+
<link rel="stylesheet" type="text/css" href="assets/stylesheets/stylesheet.css" media="screen">
11+
<link rel="stylesheet" type="text/css" href="assets/stylesheets/github-light.css" media="screen">
12+
<script src="dist/examples.min.js"></script>
1713
</head>
1814

1915
<body ng-app="ngFileSaver">

gulpfile.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var config = {
3737
},
3838
docs: {
3939
type: 'docs',
40-
entryPoint: './docs/js/custom.js',
40+
entryPoint: './docs/assets/js/custom.js',
4141
bundleName: 'examples.js',
4242
dest: './docs/dist'
4343
}
@@ -122,17 +122,18 @@ gulp.task('build', function() {
122122
sequence(['browserify']);
123123
});
124124

125+
gulp.task('build:docs', function() {
126+
config.isProd = true;
127+
browserifyDefaults = config.browserify.docs;
128+
129+
sequence(['browserify']);
130+
});
131+
125132
gulp.task('watch:docs', ['serve'], function() {
126133
gulp.watch(config.docs.styles, ['styles:docs']);
127134
gulp.watch(config.docs.templates, ['templates:docs']);
128135
gulp.watch('./CONTRIBUTING.md', ['markdown']);
129136
});
130137

131-
gulp.task('build', function() {
132-
config.isProd = true;
133-
browserifyDefaults = config.browserify.fileSaver;
134-
135-
sequence(['browserify']);
136-
});
137138

138139
gulp.task('default', ['build']);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
},
2525
"homepage": "https://github.com/alferov/angular-file-saver",
2626
"devDependencies": {
27+
"browser-filesaver": "^1.0.0",
2728
"browserify": "^11.0.1",
2829
"gulp": "^3.9.0",
2930
"gulp-gh-pages": "^0.5.2",

0 commit comments

Comments
 (0)