diff options
Diffstat (limited to 'js/CommonDialogs.js')
-rw-r--r-- | js/CommonDialogs.js | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 321ddf6d3..ab8441cac 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -3,7 +3,7 @@ /* eslint-disable new-cap */ /* eslint-disable no-new */ -/* global __, dojo, dijit, Notify, App, Feeds, xhrPost, xhr, Tables, fox */ +/* global __, dojo, dijit, Notify, App, Feeds, xhr, Tables, fox */ /* exported CommonDialogs */ const CommonDialogs = { @@ -16,7 +16,7 @@ const CommonDialogs = { {op: "feeds", method: "subscribeToFeed"}, (reply) => { const dialog = new fox.SingleUseDialog({ - title: __("Subscribe to Feed"), + title: __("Subscribe to feed"), content: ` <form onsubmit='return false'> @@ -181,7 +181,7 @@ const CommonDialogs = { } } catch (e) { - console.error(transport.responseText); + console.error(reply); App.Error.report(e); } }); @@ -248,7 +248,7 @@ const CommonDialogs = { ${reply.map((row) => ` <tr data-row-id='${row.id}'> - <td width='5%' align='center'> + <td class='checkbox'> <input onclick='Tables.onRowChecked(this)' dojoType="dijit.form.CheckBox" type="checkbox"> </td> @@ -333,8 +333,12 @@ const CommonDialogs = { const dialog = new fox.SingleUseDialog({ id: "feedEditDlg", - title: __("Edit Feed"), + title: __("Edit feed"), feed_title: "", + E_ICON_FILE_TOO_LARGE: 'E_ICON_FILE_TOO_LARGE', + E_ICON_RENAME_FAILED: 'E_ICON_RENAME_FAILED', + E_ICON_UPLOAD_FAILED: 'E_ICON_UPLOAD_FAILED', + E_ICON_UPLOAD_SUCCESS: 'E_ICON_UPLOAD_SUCCESS', unsubscribe: function() { if (confirm(__("Unsubscribe from %s?").replace("%s", this.feed_title))) { dialog.hide(); @@ -361,20 +365,18 @@ const CommonDialogs = { xhr.open( 'POST', 'backend.php', true ); xhr.onload = function () { - console.log(this.responseText); + const ret = JSON.parse(this.responseText); // TODO: make a notice box within panel content - switch (parseInt(this.responseText)) { - case 1: - Notify.error("Upload failed: icon is too big."); + switch (ret.rc) { + case dialog.E_ICON_FILE_TOO_LARGE: + alert(__("Icon file is too large.")); break; - case 2: - Notify.error("Upload failed."); + case dialog.E_ICON_UPLOAD_FAILED: + alert(__("Upload failed.")); break; - default: + case dialog.E_ICON_UPLOAD_SUCCESS: { - Notify.info("Upload complete."); - if (App.isPrefs()) dijit.byId("feedTree").reload(); else @@ -383,12 +385,16 @@ const CommonDialogs = { const icon = dialog.domNode.querySelector(".feedIcon"); if (icon) { - icon.src = this.responseText; + icon.src = ret.icon_url; icon.show(); } input.value = ""; } + break; + default: + alert(this.responseText); + break; } }; @@ -400,9 +406,7 @@ const CommonDialogs = { if (confirm(__("Remove stored feed icon?"))) { Notify.progress("Removing feed icon...", true); - const query = {op: "pref-feeds", method: "removeicon", feed_id: id}; - - xhr.post("backend.php", query, () => { + xhr.post("backend.php", {op: "pref-feeds", method: "removeicon", feed_id: id}, () => { Notify.info("Feed icon removed."); if (App.isPrefs()) @@ -473,8 +477,8 @@ const CommonDialogs = { <section> <fieldset> <input dojoType='dijit.form.ValidationTextBox' required='1' - placeHolder="${__("Feed Title")}" - style='font-size : 16px; width: 500px' name='title' value="${App.escapeHtml(feed.title)}"> + placeHolder="${__("Feed title")}" + style='font-size : 16px; width: 530px' name='title' value="${App.escapeHtml(feed.title)}"> </fieldset> <fieldset> @@ -565,19 +569,21 @@ const CommonDialogs = { <div dojoType="dijit.layout.ContentPane" title="${__('Icon')}"> <div><img class='feedIcon' style="${feed.icon ? "" : "display : none"}" src="${feed.icon ? App.escapeHtml(feed.icon) : ""}"></div> - <label class="dijitButton">${__("Upload new icon...")} + <label class="dijitButton"> + ${App.FormFields.icon("file_upload")} + ${__("Upload new icon...")} <input style="display: none" type="file" onchange="App.dialogOf(this).uploadIcon(this)"> </label> - ${App.FormFields.submit_tag(__("Remove"), {class: "alt-danger", onclick: "App.dialogOf(this).removeIcon("+feed_id+")"})} + ${App.FormFields.submit_tag(App.FormFields.icon("delete") + " " + __("Remove"), {class: "alt-danger", onclick: "App.dialogOf(this).removeIcon("+feed_id+")"})} </div> <div dojoType="dijit.layout.ContentPane" title="${__('Plugins')}"> ${reply.plugin_data} </div> </div> <footer> - ${App.FormFields.button_tag(__("Unsubscribe"), "", {class: "pull-left alt-danger", onclick: "App.dialogOf(this).unsubscribe()"})} - ${App.FormFields.submit_tag(__("Save"), {onclick: "App.dialogOf(this).execute()"})} + ${App.FormFields.button_tag(App.FormFields.icon("delete") + " " + __("Unsubscribe"), "", {class: "pull-left alt-danger", onclick: "App.dialogOf(this).unsubscribe()"})} + ${App.FormFields.submit_tag(App.FormFields.icon("save") + " " + __("Save"), {onclick: "App.dialogOf(this).execute()"})} ${App.FormFields.cancel_dialog_tag(__("Cancel"))} </footer> </form> @@ -634,6 +640,7 @@ const CommonDialogs = { onclick='window.open("https://tt-rss.org/wiki/GeneratedFeeds")'> <i class='material-icons'>help</i> ${__("More info...")}</button> <button dojoType='dijit.form.Button' onclick="return App.dialogOf(this).regenFeedKey('${feed}', '${is_cat}')"> + ${App.FormFields.icon("refresh")} ${__('Generate new URL')} </button> <button dojoType='dijit.form.Button' class='alt-primary' type='submit'> |