fix cannot open torrent file sometimes

This commit is contained in:
MaysWind 2018-05-10 00:42:09 +08:00
parent 1588af21b7
commit ee1ea1626c
3 changed files with 40 additions and 31 deletions

View file

@ -120,7 +120,7 @@
$scope.changeTab('options');
}, function (error) {
ariaNgCommonService.showError(error);
});
}, angular.element('#file-holder'));
};
$scope.openMetalink = function () {
@ -130,7 +130,7 @@
$scope.changeTab('options');
}, function (error) {
ariaNgCommonService.showError(error);
});
}, angular.element('#file-holder'));
};
$scope.startDownload = function (pauseOnAdded) {

View file

@ -46,7 +46,7 @@
};
return {
openFileContent: function (fileFilter, successCallback, errorCallback) {
openFileContent: function (fileFilter, successCallback, errorCallback, element) {
if (!isSupportFileReader) {
if (errorCallback) {
errorCallback('Your browser does not support loading file!');
@ -57,7 +57,12 @@
var allowedExtensions = getAllowedExtensions(fileFilter);
angular.element('<input type="file" style="display: none"/>').change(function () {
if (!element || !element.change) {
element = angular.element('<input type="file" style="display: none"/>');
}
if (element.attr('data-ariang-file-initialized') !== 'true') {
element.change(function () {
if (!this.files || this.files.length < 1) {
return;
}
@ -93,7 +98,10 @@
};
reader.readAsDataURL(file);
}).trigger('click');
}).attr('data-ariang-file-initialized', 'true');
}
element.trigger('click');
}
};
}]);

View file

@ -61,6 +61,7 @@
</div>
</div>
</div>
<input id="file-holder" type="file" style="display: none"/>
</div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'options'}">
<div class="settings-table striped hoverable">