summaryrefslogtreecommitdiffstats
path: root/js/settings.js
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-11-04 22:27:09 -0500
committerAlessandro Cosentino <cosenal@gmail.com>2012-11-04 22:27:09 -0500
commita4d88f696a9a38a128b323889ce05cb92048f5a9 (patch)
treef8946e2aa75f44ec47a8a14f39d9bb701a48f248 /js/settings.js
parent4e905c5e106706c01e9d758ab5c2dd5c62b0af12 (diff)
[News] substitutes modals with notification in importopml
Diffstat (limited to 'js/settings.js')
-rw-r--r--js/settings.js51
1 files changed, 30 insertions, 21 deletions
diff --git a/js/settings.js b/js/settings.js
index 1eedcbfd0..0f8b5bc38 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -4,7 +4,7 @@ News.Settings={
cloudFileSelected:function(path){
$.getJSON(OC.filePath('news', 'ajax', 'selectfromcloud.php'),{'path':path},function(jsondata){
if(jsondata.status == 'success'){
- News.Settings.importOpml(jsondata.data.tmp);
+ News.Settings.importOpml('fromCloud', jsondata.data.tmp);
}
else{
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
@@ -21,35 +21,44 @@ News.Settings={
//check file format/size/...
var formData = new FormData();
formData.append('file', file);
- $.ajax({
+
+ News.Settings.importOpml('fromFile', formData);
+ $('#appsettings_popup').remove();
+ },
+ importOpml:function(type, data){
+
+ $('#notification').fadeIn();
+ $('#notification').html(t('news', 'Importing OPML file...'));
+
+ if (type == 'fromCloud') {
+ ajaxData = { path: data };
+ settings = {};
+ }
+ else if (type == 'fromFile') {
+ ajaxData = data;
+ settings = { cache: false, contentType: false, processData: false };
+ }
+ else {
+ throw t('news', 'Not a valid type');
+ }
+
+ param = {
url: OC.filePath('news', 'ajax', 'importopml.php'),
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
+ data: ajaxData,
type: 'POST',
success: function(jsondata){
if (jsondata.status == 'success') {
- var message = jsondata.data.countsuccess + t('news', ' out of ') + jsondata.data.count +
- t('news', ' feeds imported successfully from ') + jsondata.data.title;
- OC.dialogs.alert(message, t('news', 'Success'));
+ $('#notification').html(t('files', '{n_success} out of {n_total} feeds imported successfully!',
+ {n_success: jsondata.data.countsuccess, n_total: jsondata.data.count}));
}
else {
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
+ $('#notification').delay('2500').fadeOut('400');
}
- });
- },
- importOpml:function(path){
- $.post(OC.filePath('news', 'ajax', 'importopml.php'), { path: path }, function(jsondata){
- if (jsondata.status == 'success') {
- var message = jsondata.data.countsuccess + t('news', ' out of ') + jsondata.data.count +
- t('news', ' feeds imported successfully from ') + jsondata.data.title;
- OC.dialogs.alert(message, t('news', 'Success'));
- } else {
- OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
- }
- });
+ };
+
+ $.ajax($.extend(param, settings));
},
exportOpml:function(button){
document.location.href = OC.linkTo('news', 'opmlexporter.php');