|
1 | 1 | /*
|
2 |
| - * jQuery File Upload AngularJS Plugin 2.1.3 |
| 2 | + * jQuery File Upload AngularJS Plugin 2.2.0 |
3 | 3 | * https://github.com/blueimp/jQuery-File-Upload
|
4 | 4 | *
|
5 | 5 | * Copyright 2013, Sebastian Tschan
|
|
38 | 38 | .provider('fileUpload', function () {
|
39 | 39 | var scopeEvalAsync = function (expression) {
|
40 | 40 | var scope = angular.element(this)
|
41 |
| - .fileupload('option', 'scope')(); |
| 41 | + .fileupload('option', 'scope'); |
42 | 42 | // Schedule a new $digest cycle if not already inside of one
|
43 | 43 | // and evaluate the given expression:
|
44 | 44 | scope.$evalAsync(expression);
|
|
75 | 75 | handleResponse: function (e, data) {
|
76 | 76 | var files = data.result && data.result.files;
|
77 | 77 | if (files) {
|
78 |
| - data.scope().replace(data.files, files); |
| 78 | + data.scope.replace(data.files, files); |
79 | 79 | } else if (data.errorThrown ||
|
80 | 80 | data.textStatus === 'error') {
|
81 | 81 | data.files[0].error = data.errorThrown ||
|
|
86 | 86 | if (e.isDefaultPrevented()) {
|
87 | 87 | return false;
|
88 | 88 | }
|
89 |
| - var scope = data.scope(), |
| 89 | + var scope = data.scope, |
90 | 90 | filesCopy = [];
|
91 | 91 | angular.forEach(data.files, function (file) {
|
92 | 92 | filesCopy.push(file);
|
|
116 | 116 | if (e.isDefaultPrevented()) {
|
117 | 117 | return false;
|
118 | 118 | }
|
119 |
| - data.scope().$apply(); |
| 119 | + data.scope.$apply(); |
120 | 120 | },
|
121 | 121 | done: function (e, data) {
|
122 | 122 | if (e.isDefaultPrevented()) {
|
123 | 123 | return false;
|
124 | 124 | }
|
125 | 125 | var that = this;
|
126 |
| - data.scope().$apply(function () { |
| 126 | + data.scope.$apply(function () { |
127 | 127 | data.handleResponse.call(that, e, data);
|
128 | 128 | });
|
129 | 129 | },
|
|
132 | 132 | return false;
|
133 | 133 | }
|
134 | 134 | var that = this,
|
135 |
| - scope = data.scope(); |
| 135 | + scope = data.scope; |
136 | 136 | if (data.errorThrown === 'abort') {
|
137 | 137 | scope.clear(data.files);
|
138 | 138 | return;
|
|
145 | 145 | processstart: scopeEvalAsync,
|
146 | 146 | processstop: scopeEvalAsync,
|
147 | 147 | getNumberOfFiles: function () {
|
148 |
| - var scope = this.scope(); |
| 148 | + var scope = this.scope; |
149 | 149 | return scope.queue.length - scope.processing();
|
150 | 150 | },
|
151 | 151 | dataType: 'json',
|
|
207 | 207 | return $element.fileupload('active');
|
208 | 208 | },
|
209 | 209 | option: function (option, data) {
|
210 |
| - return $element.fileupload('option', option, data); |
| 210 | + if (arguments.length === 1) { |
| 211 | + return $element.fileupload('option', option); |
| 212 | + } |
| 213 | + $element.fileupload('option', option, data); |
211 | 214 | },
|
212 | 215 | add: function (data) {
|
213 | 216 | return $element.fileupload('add', data);
|
|
277 | 280 | // the options provided via "data-"-parameters,
|
278 | 281 | // as well as those given via options object:
|
279 | 282 | $element.fileupload(angular.extend(
|
280 |
| - {scope: function () { |
281 |
| - return $scope; |
282 |
| - }}, |
| 283 | + {scope: $scope}, |
283 | 284 | fileUpload.defaults
|
284 | 285 | )).on('fileuploadadd', function (e, data) {
|
285 |
| - data.scope = $scope.option('scope'); |
| 286 | + data.scope = $scope; |
286 | 287 | }).on('fileuploadfail', function (e, data) {
|
287 | 288 | if (data.errorThrown === 'abort') {
|
288 | 289 | return;
|
|
0 commit comments