Skip to content

Commit ed7400e

Browse files
author
Philipp Alferov
committed
Use angular-file-saver-bundle for the docs
1 parent b1a59af commit ed7400e

File tree

3 files changed

+241
-34
lines changed

3 files changed

+241
-34
lines changed

docs/assets/js/custom.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
'use strict'
12
var angular = require('angular');
2-
var fileSaver = require('../../../src/angular-file-saver.module');
3-
window.saveAs = require('FileSaver.js').saveAs;
3+
require('../../../src/angular-file-saver-bundle.module');
44

5-
function DownloadText($scope, FileSaver) {
5+
function DownloadText(FileSaver) {
66
var vm = this;
77

88
vm.val = {
@@ -25,4 +25,4 @@ function DownloadText($scope, FileSaver) {
2525

2626
angular
2727
.module('fileSaverExample', ['ngFileSaver'])
28-
.controller('DownloadText', ['$scope', 'FileSaver', DownloadText]);
28+
.controller('DownloadText', ['FileSaver', DownloadText]);

docs/dist/examples.js

Lines changed: 231 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2+
'use strict'
23
var angular = require('angular');
3-
var fileSaver = require('../../../src/angular-file-saver.module');
4-
window.saveAs = require('FileSaver.js').saveAs;
4+
require('../../../src/angular-file-saver-bundle.module');
55

6-
function DownloadText($scope, FileSaver) {
6+
function DownloadText(FileSaver) {
77
var vm = this;
88

99
vm.val = {
@@ -26,9 +26,222 @@ function DownloadText($scope, FileSaver) {
2626

2727
angular
2828
.module('fileSaverExample', ['ngFileSaver'])
29-
.controller('DownloadText', ['$scope', 'FileSaver', DownloadText]);
29+
.controller('DownloadText', ['FileSaver', DownloadText]);
3030

31-
},{"../../../src/angular-file-saver.module":5,"FileSaver.js":2,"angular":4}],2:[function(require,module,exports){
31+
},{"../../../src/angular-file-saver-bundle.module":6,"angular":5}],2:[function(require,module,exports){
32+
/* Blob.js
33+
* A Blob implementation.
34+
* 2014-07-24
35+
*
36+
* By Eli Grey, http://eligrey.com
37+
* By Devin Samarin, https://github.com/dsamarin
38+
* License: X11/MIT
39+
* See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md
40+
*/
41+
42+
/*global self, unescape */
43+
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
44+
plusplus: true */
45+
46+
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
47+
48+
(function (view) {
49+
"use strict";
50+
51+
view.URL = view.URL || view.webkitURL;
52+
53+
if (view.Blob && view.URL) {
54+
try {
55+
new Blob;
56+
return;
57+
} catch (e) {}
58+
}
59+
60+
// Internally we use a BlobBuilder implementation to base Blob off of
61+
// in order to support older browsers that only have BlobBuilder
62+
var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
63+
var
64+
get_class = function(object) {
65+
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
66+
}
67+
, FakeBlobBuilder = function BlobBuilder() {
68+
this.data = [];
69+
}
70+
, FakeBlob = function Blob(data, type, encoding) {
71+
this.data = data;
72+
this.size = data.length;
73+
this.type = type;
74+
this.encoding = encoding;
75+
}
76+
, FBB_proto = FakeBlobBuilder.prototype
77+
, FB_proto = FakeBlob.prototype
78+
, FileReaderSync = view.FileReaderSync
79+
, FileException = function(type) {
80+
this.code = this[this.name = type];
81+
}
82+
, file_ex_codes = (
83+
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
84+
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
85+
).split(" ")
86+
, file_ex_code = file_ex_codes.length
87+
, real_URL = view.URL || view.webkitURL || view
88+
, real_create_object_URL = real_URL.createObjectURL
89+
, real_revoke_object_URL = real_URL.revokeObjectURL
90+
, URL = real_URL
91+
, btoa = view.btoa
92+
, atob = view.atob
93+
94+
, ArrayBuffer = view.ArrayBuffer
95+
, Uint8Array = view.Uint8Array
96+
97+
, origin = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/
98+
;
99+
FakeBlob.fake = FB_proto.fake = true;
100+
while (file_ex_code--) {
101+
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
102+
}
103+
// Polyfill URL
104+
if (!real_URL.createObjectURL) {
105+
URL = view.URL = function(uri) {
106+
var
107+
uri_info = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
108+
, uri_origin
109+
;
110+
uri_info.href = uri;
111+
if (!("origin" in uri_info)) {
112+
if (uri_info.protocol.toLowerCase() === "data:") {
113+
uri_info.origin = null;
114+
} else {
115+
uri_origin = uri.match(origin);
116+
uri_info.origin = uri_origin && uri_origin[1];
117+
}
118+
}
119+
return uri_info;
120+
};
121+
}
122+
URL.createObjectURL = function(blob) {
123+
var
124+
type = blob.type
125+
, data_URI_header
126+
;
127+
if (type === null) {
128+
type = "application/octet-stream";
129+
}
130+
if (blob instanceof FakeBlob) {
131+
data_URI_header = "data:" + type;
132+
if (blob.encoding === "base64") {
133+
return data_URI_header + ";base64," + blob.data;
134+
} else if (blob.encoding === "URI") {
135+
return data_URI_header + "," + decodeURIComponent(blob.data);
136+
} if (btoa) {
137+
return data_URI_header + ";base64," + btoa(blob.data);
138+
} else {
139+
return data_URI_header + "," + encodeURIComponent(blob.data);
140+
}
141+
} else if (real_create_object_URL) {
142+
return real_create_object_URL.call(real_URL, blob);
143+
}
144+
};
145+
URL.revokeObjectURL = function(object_URL) {
146+
if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
147+
real_revoke_object_URL.call(real_URL, object_URL);
148+
}
149+
};
150+
FBB_proto.append = function(data/*, endings*/) {
151+
var bb = this.data;
152+
// decode data to a binary string
153+
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
154+
var
155+
str = ""
156+
, buf = new Uint8Array(data)
157+
, i = 0
158+
, buf_len = buf.length
159+
;
160+
for (; i < buf_len; i++) {
161+
str += String.fromCharCode(buf[i]);
162+
}
163+
bb.push(str);
164+
} else if (get_class(data) === "Blob" || get_class(data) === "File") {
165+
if (FileReaderSync) {
166+
var fr = new FileReaderSync;
167+
bb.push(fr.readAsBinaryString(data));
168+
} else {
169+
// async FileReader won't work as BlobBuilder is sync
170+
throw new FileException("NOT_READABLE_ERR");
171+
}
172+
} else if (data instanceof FakeBlob) {
173+
if (data.encoding === "base64" && atob) {
174+
bb.push(atob(data.data));
175+
} else if (data.encoding === "URI") {
176+
bb.push(decodeURIComponent(data.data));
177+
} else if (data.encoding === "raw") {
178+
bb.push(data.data);
179+
}
180+
} else {
181+
if (typeof data !== "string") {
182+
data += ""; // convert unsupported types to strings
183+
}
184+
// decode UTF-16 to binary string
185+
bb.push(unescape(encodeURIComponent(data)));
186+
}
187+
};
188+
FBB_proto.getBlob = function(type) {
189+
if (!arguments.length) {
190+
type = null;
191+
}
192+
return new FakeBlob(this.data.join(""), type, "raw");
193+
};
194+
FBB_proto.toString = function() {
195+
return "[object BlobBuilder]";
196+
};
197+
FB_proto.slice = function(start, end, type) {
198+
var args = arguments.length;
199+
if (args < 3) {
200+
type = null;
201+
}
202+
return new FakeBlob(
203+
this.data.slice(start, args > 1 ? end : this.data.length)
204+
, type
205+
, this.encoding
206+
);
207+
};
208+
FB_proto.toString = function() {
209+
return "[object Blob]";
210+
};
211+
FB_proto.close = function() {
212+
this.size = 0;
213+
delete this.data;
214+
};
215+
return FakeBlobBuilder;
216+
}(view));
217+
218+
view.Blob = function(blobParts, options) {
219+
var type = options ? (options.type || "") : "";
220+
var builder = new BlobBuilder();
221+
if (blobParts) {
222+
for (var i = 0, len = blobParts.length; i < len; i++) {
223+
if (Uint8Array && blobParts[i] instanceof Uint8Array) {
224+
builder.append(blobParts[i].buffer);
225+
}
226+
else {
227+
builder.append(blobParts[i]);
228+
}
229+
}
230+
}
231+
var blob = builder.getBlob(type);
232+
if (!blob.slice && blob.webkitSlice) {
233+
blob.slice = blob.webkitSlice;
234+
}
235+
return blob;
236+
};
237+
238+
var getPrototypeOf = Object.getPrototypeOf || function(object) {
239+
return object.__proto__;
240+
};
241+
view.Blob.prototype = getPrototypeOf(new view.Blob());
242+
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
243+
244+
},{}],3:[function(require,module,exports){
32245
/* FileSaver.js
33246
* A saveAs() FileSaver implementation.
34247
* 1.1.20150716
@@ -286,7 +499,7 @@ if (typeof module !== "undefined" && module.exports) {
286499
});
287500
}
288501

289-
},{}],3:[function(require,module,exports){
502+
},{}],4:[function(require,module,exports){
290503
/**
291504
* @license AngularJS v1.4.5
292505
* (c) 2010-2015 Google, Inc. http://angularjs.org
@@ -28975,11 +29188,11 @@ $provide.value("$locale", {
2897529188
})(window, document);
2897629189

2897729190
!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>');
28978-
},{}],4:[function(require,module,exports){
29191+
},{}],5:[function(require,module,exports){
2897929192
require('./angular');
2898029193
module.exports = angular;
2898129194

28982-
},{"./angular":3}],5:[function(require,module,exports){
29195+
},{"./angular":4}],6:[function(require,module,exports){
2898329196
'use strict';
2898429197

2898529198
/*
@@ -28995,22 +29208,14 @@ module.exports = angular;
2899529208
angular.module('ngFileSaver', [])
2899629209
.factory('FileSaver', ['Blob', 'SaveAs', 'FileSaverUtils', require('./angular-file-saver.service')])
2899729210
.factory('FileSaverUtils', [require('./utils/utils.service.js')])
28998-
.factory('Blob', ['$window', require('./dependencies/blob.service.js')])
28999-
.factory('SaveAs', ['$window', require('./dependencies/file-saver.service.js')]);
29211+
.factory('Blob', ['$window', require('./dependencies/blob-bundle.service.js')])
29212+
.factory('SaveAs', [require('./dependencies/file-saver-bundle.service.js')]);
2900029213

29001-
},{"./angular-file-saver.service":6,"./dependencies/blob.service.js":7,"./dependencies/file-saver.service.js":8,"./utils/utils.service.js":9}],6:[function(require,module,exports){
29214+
},{"./angular-file-saver.service":7,"./dependencies/blob-bundle.service.js":8,"./dependencies/file-saver-bundle.service.js":9,"./utils/utils.service.js":10}],7:[function(require,module,exports){
2900229215
'use strict';
2900329216

2900429217
module.exports = function FileSaver(Blob, SaveAs, FileSaverUtils) {
2900529218

29006-
if (FileSaverUtils.isUndefined(FileSaver)) {
29007-
FileSaverUtils.handleErrors('saveAs is not supported. Please include saveAs polyfill');
29008-
}
29009-
29010-
if (FileSaverUtils.isUndefined(Blob)) {
29011-
FileSaverUtils.handleErrors('Blob is not supported. Please include blob polyfill');
29012-
}
29013-
2901429219
function isBlobInstance(obj) {
2901529220
return obj instanceof Blob;
2901629221
}
@@ -29058,21 +29263,23 @@ module.exports = function FileSaver(Blob, SaveAs, FileSaverUtils) {
2905829263
};
2905929264
};
2906029265

29061-
},{}],7:[function(require,module,exports){
29266+
},{}],8:[function(require,module,exports){
2906229267
'use strict';
2906329268

29269+
require('Blob.js');
29270+
2906429271
module.exports = function Blob($window) {
2906529272
return $window.Blob;
2906629273
};
2906729274

29068-
},{}],8:[function(require,module,exports){
29275+
},{"Blob.js":2}],9:[function(require,module,exports){
2906929276
'use strict';
2907029277

29071-
module.exports = function SaveAs($window) {
29072-
return $window.saveAs;
29278+
module.exports = function SaveAs() {
29279+
return require('FileSaver.js').saveAs;
2907329280
};
2907429281

29075-
},{}],9:[function(require,module,exports){
29282+
},{"FileSaver.js":3}],10:[function(require,module,exports){
2907629283
'use strict';
2907729284

2907829285
module.exports = function FileSaverUtils() {

0 commit comments

Comments
 (0)