offset.left *= 2;
offset.top *= 2;
- if ($(e).data('ios-preview') == '1') {
+ if ($(e).data('ios-preview') === '1') {
offset.top = offset.left = 0;
}
} catch (err) {
if (this.datas.phonegap === 'android') {
if (types_android[type] !== undefined) {
+
+ var errorCallback = function (e) {
+ $this.bugreport(e);
+ $this.hideLoader();
+ };
+
console.log('open pdf file');
this.displayLoader();
- window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function (fileSystem) {
- console.log('got local file system');
- console.log('try to resolve url');
- window.resolveLocalFileSystemURL(url, function (entry) {
- console.log('resolved from file');
- window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) {
- console.log('resolved to dir');
- entry.copyTo(dirEntry, 'document.pdf', function (copyEntry) {
- console.log('copied file');
- window.plugins.webintent.startActivity({
- action: window.plugins.webintent.ACTION_VIEW,
- type: types_android[type],
- url: copyEntry.toURL()
- }, function (args) {
- $this.hideLoader(5);
- }, function (args) {
- $this.wopen(copyEntry.toURL(), '_blank', '');
- $this.hideLoader(5);
- });
- }, lazy);
- }, lazy);
- }, lazy);
- }, lazy);
+ try {
+ window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function (fileSystem) {
+ console.log('got local file system');
+ console.log('try to resolve url');
+ window.resolveLocalFileSystemURL(url, function (entry) {
+ console.log('resolved from file');
+ window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) {
+ console.log('resolved to dir');
+ entry.copyTo(dirEntry, entry.name, function (copyEntry) {
+ console.log('copied file');
+ window.plugins.webintent.startActivity({
+ action: window.plugins.webintent.ACTION_VIEW,
+ type: types_android[type],
+ url: copyEntry.toURL()
+ }, function (args) {
+ $this.hideLoader(5);
+ }, function (args) {
+ $this.wopen(copyEntry.toURL(), '_blank', '');
+ $this.hideLoader(5);
+ });
+ }, errorCallback);
+ }, errorCallback);
+ }, errorCallback);
+ }, errorCallback);
+ } catch (e) {
+ $this.bugreport(e);
+ $this.hideLoader();
+ }
}
return true;
}
$this.flushNetworkQueue();
}, 100);
},
+
+ bugreport: function (e) {
+ if (window.confirm('An error occured: ' + e.name + '. Do you want to send a report ?')) {
+ var subject = '[Fluidbook report] ' + e.message;
+ window.open('mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(e)));
+ }
+ },
}