Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Commit ca65d6c

Browse files
author
Joshua Smith
committed
Fix problems with spinners and banners
1 parent 7a69e9b commit ca65d6c

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

scripts/cloud/dropbox.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,22 @@ cloud.dropbox.enumerate = function (directory, callback) {
7777

7878
cloud.dropbox.load = function (path, callback) {
7979
if (cloud.dropbox.client && path) {
80-
spinner();
8180
cloud.dropbox.client.readFile(path, function(e, d) {
81+
// Hide spinner
8282
spinner('hide');
83+
84+
// Callback
8385
if (!e) {
8486
callback(d);
8587
} else {
8688
callback(e.status, true);
8789
}
8890
});
8991
} else {
92+
// Hide spinner
93+
spinner('hide');
94+
95+
// Callback error
9096
if (!cloud.dropbox.client) {
9197
callback("You are not signed in to Dropbox", true);
9298
} else if (!path) {

scripts/io.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ firetext.io.save = function (directory, filename, filetype, content, showBanner,
536536
}
537537

538538
// Finish
539-
updateDocLists(['recents']);
540539
saving = false;
541540
callback();
542541
};
@@ -593,14 +592,26 @@ firetext.io.save = function (directory, filename, filetype, content, showBanner,
593592
});
594593
}
595594
} else if (location == 'dropbox') {
596-
cloud.dropbox.save(filePath, contentBlob, showSpinner, function () { saving = false; callback(); });
595+
cloud.dropbox.save(filePath, contentBlob, showSpinner, function () {
596+
// Show banner
597+
if (showBanner) {
598+
showSaveBanner();
599+
}
600+
601+
// Finish
602+
saving = false;
603+
callback();
604+
});
597605
}
598606
};
599607

600608
firetext.io.load = function (directory, filename, filetype, callback, location) {
601609
if (!directory | !filename | !filetype | !callback) {
602610
return;
603611
}
612+
613+
// Show spinner
614+
spinner();
604615

605616
// Put directory in proper form
606617
if (directory[directory.length - 1] != '/') {
@@ -630,7 +641,10 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
630641
// 0.3 only
631642
reader.readAsText(file);
632643

633-
reader.onerror = function () {
644+
reader.onerror = function () {
645+
// Hide spinner
646+
spinner('hide');
647+
634648
alert('Load unsuccessful :( \n\nInfo for gurus:\n"' + this.error.name + '"');
635649
callback(this.error.name, true);
636650
};
@@ -648,6 +662,9 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
648662
// 0.3 only
649663
file = this.result;
650664

665+
// Hide spinner
666+
spinner('hide');
667+
651668
callback(file);
652669
};
653670
};
@@ -658,13 +675,19 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
658675
else {
659676
alert('Load unsuccessful :( \n\nInfo for gurus:\n"' + this.error.name + '"');
660677
}
678+
679+
// Hide spinner
680+
spinner('hide');
661681
};
662682
} else if (deviceAPI == 'file') {
663683
storage.root.getFile(directory + filename + filetype, {}, function(fileEntry) {
664684
fileEntry.file(function(file) {
665685
var reader = new FileReader();
666686

667687
reader.onerror = function () {
688+
// Hide spinner
689+
spinner('hide');
690+
668691
alert('Load unsuccessful :( \n\nInfo for gurus:\n"' + this.error.name + '"');
669692
callback(this.error.name, true);
670693
};
@@ -680,6 +703,9 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
680703
// 0.3 only
681704
file = this.result;
682705

706+
// Hide spinner
707+
spinner('hide');
708+
683709
callback(file);
684710
};
685711

@@ -695,17 +721,26 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
695721
reader.readAsText(file);
696722
}, function(err) {
697723
alert("Error opening file\n\ncode: " + err.code);
724+
725+
// Hide spinner
726+
spinner('hide');
698727
});
699728
}, function(err) {
700729
if (err.code === FileError.NOT_FOUND_ERR) {
701730
alert("Load unsuccessful :(\n\nError code: " + err.code);
702731
} else {
703732
alert("Load unsuccessful :(\n\nError code: " + err.code);
704733
}
734+
735+
// Hide spinner
736+
spinner('hide');
705737
});
706738
}
707739
} else if (location = 'dropbox') {
708740
cloud.dropbox.load(filePath, function (result, error) {
741+
// Hide spinner
742+
spinner('hide');
743+
709744
callback(result, error);
710745
});
711746
}

0 commit comments

Comments
 (0)