Skip to content
Browse files

Added an option to suppress success message on page save

  • Loading branch information...
1 parent bf31b6a commit 0501dc6ed8bd4dc48c3e1c34765f015f327f6197 @yuvipanda yuvipanda committed May 17, 2012
Showing with 16 additions and 8 deletions.
  1. +4 −2 assets/www/android/platform.js
  2. +4 −2 assets/www/ios/platform.js
  3. +8 −4 assets/www/js/savedpages.js
View
6 assets/www/android/platform.js
@@ -186,7 +186,7 @@ window.preferencesDB.addOnSet(function(id, value) {
window.plugins.preferences.set(id, value, function(){}, function(){});
});
-savedPages.doSave = function() {
+savedPages.doSave = function(options) {
console.log("Saving page");
chrome.showSpinner();
var page = app.curPage;
@@ -205,7 +205,9 @@ savedPages.doSave = function() {
);
});
app.track('mobile.app.wikipedia.save-page');
- chrome.showNotification(mw.message('page-saved', app.curPage.title).plain());
+ if(!options.silent) {
+ chrome.showNotification(mw.message('page-saved', app.curPage.title).plain());
+ }
chrome.hideSpinner();
d.resolve();
}
View
6 assets/www/ios/platform.js
@@ -32,7 +32,7 @@ app.loadCachedPage = function (url) {
});
}
-savedPages.doSave = function() {
+savedPages.doSave = function(options) {
var d = $.Deferred();
var url = app.curPage.getAPIUrl();
var data = JSON.stringify(app.curPage);
@@ -41,7 +41,9 @@ savedPages.doSave = function() {
chrome.populateSection(section.id);
});
urlCache.saveCompleteHtml(url, data, $("#main")).then(function() {
- chrome.showNotification(mw.message('page-saved', app.curPage.title).plain());
+ if(!options.silent) {
+ chrome.showNotification(mw.message('page-saved', app.curPage.title).plain());
+ }
app.track('mobile.app.wikipedia.save-page');
chrome.hideSpinner();
d.resolve();
View
12 assets/www/js/savedpages.js
@@ -3,7 +3,9 @@ window.savedPages = function() {
// Increment when format of saved pages changes
window.SAVED_PAGES_VERSION = 1;
- function doSave() {
+ // Options:
+ // silent: set to true to prevent notification of successful saving
+ function doSave(options) {
// Overriden in appropriate platform files
}
@@ -29,7 +31,7 @@ window.savedPages = function() {
function saveNextPage(curPage) {
$("#migration-status").html(mw.msg('migrating-saved-page-status', pages[curPage].title));
app.navigateToPage(pages[curPage].key).done(function() {
- savedPages.saveCurrentPage().done(function() {
+ savedPages.saveCurrentPage({silent: true}).done(function() {
savedPagesDB.remove(pages[curPage].key);
// curPage + 1 < pages.length
// since curpage + 1 is what we pass to the next call
@@ -52,10 +54,12 @@ window.savedPages = function() {
return d;
}
- function saveCurrentPage() {
+ function saveCurrentPage(options) {
var d = $.Deferred();
var MAX_LIMIT = 50;
+ options = $.extend({silent: false}, options);
+
var title = app.getCurrentTitle();
var url = app.getCurrentUrl();
@@ -69,7 +73,7 @@ window.savedPages = function() {
alert(mw.message("saved-pages-max-warning").plain());
}else{
savedPagesDB.save({key: app.curPage.getAPIUrl(), title: title, lang: app.curPage.lang, version: SAVED_PAGES_VERSION});
- savedPages.doSave(app.curPage.getAPIUrl(), title).done(function() {
+ savedPages.doSave(options).done(function() {
d.resolve()
}).fail(function() {
d.reject();

0 comments on commit 0501dc6

Please sign in to comment.
Something went wrong with that request. Please try again.