diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-11-04 22:27:09 -0500 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-11-04 22:27:09 -0500 |
commit | a4d88f696a9a38a128b323889ce05cb92048f5a9 (patch) | |
tree | f8946e2aa75f44ec47a8a14f39d9bb701a48f248 | |
parent | 4e905c5e106706c01e9d758ab5c2dd5c62b0af12 (diff) |
[News] substitutes modals with notification in importopml
-rw-r--r-- | ajax/importopml.php | 4 | ||||
-rw-r--r-- | js/main.js | 2 | ||||
-rw-r--r-- | js/settings.js | 51 | ||||
-rw-r--r-- | templates/main.php | 2 |
4 files changed, 35 insertions, 24 deletions
diff --git a/ajax/importopml.php b/ajax/importopml.php index 3573a1069..478cc1369 100644 --- a/ajax/importopml.php +++ b/ajax/importopml.php @@ -61,8 +61,8 @@ function importFeed($feedurl, $folderid) { $feedid = $feedmapper->save($feed, $folderid); } } else { - OCP\Util::writeLog('news','ajax/importopml.php: Error adding feed: '. $feedurl, OCP\Util::ERROR); - return false; + OCP\Util::writeLog('news','ajax/importopml.php: This feed is already here: '. $feedurl, OCP\Util::WARN); + return true; } if($feed === null || !$feedid) { diff --git a/js/main.js b/js/main.js index e5a313841..a7c8de77b 100644 --- a/js/main.js +++ b/js/main.js @@ -15,7 +15,7 @@ var News = News || {}; $(document).ready(function(){ // config values - var menuUpdateIntervalMiliseconds = 60000; + var menuUpdateIntervalMiliseconds = 6000000; // global object array for accessing instances News.Objects = {}; 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'); diff --git a/templates/main.php b/templates/main.php index ccc8c5261..f447c9f30 100644 --- a/templates/main.php +++ b/templates/main.php @@ -59,3 +59,5 @@ echo $this->inc("part.dialogues"); <div id="appsettings" class="popup bottomleft hidden"></div> </div> + +<div id='notification'></div>
\ No newline at end of file |