From 42b5564d1e4c06b18e37071459e04f6fcd36a85a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 15 Sep 2020 18:47:19 +0300 Subject: editarticletags: load dialog via XHR --- js/Article.js | 71 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) (limited to 'js') diff --git a/js/Article.js b/js/Article.js index 174015a61..1fc5bc9ab 100644 --- a/js/Article.js +++ b/js/Article.js @@ -257,53 +257,56 @@ const Article = { return false; }, editTags: function (id) { - const query = "backend.php?op=article&method=editArticleTags¶m=" + encodeURIComponent(id); - if (dijit.byId("editTagsDlg")) dijit.byId("editTagsDlg").destroyRecursive(); - const dialog = new dijit.Dialog({ - id: "editTagsDlg", - title: __("Edit article Tags"), - style: "width: 600px", - execute: function () { - if (this.validate()) { - Notify.progress("Saving article tags...", true); + xhrPost("backend.php", {op: "article", method: "editarticletags", param: id}, (transport) => { + + const dialog = new dijit.Dialog({ + id: "editTagsDlg", + title: __("Edit article Tags"), + style: "width: 600px", + content: transport.responseText, + execute: function () { + if (this.validate()) { + Notify.progress("Saving article tags...", true); - xhrPost("backend.php", this.attr('value'), (transport) => { - try { - Notify.close(); - dialog.hide(); + xhrPost("backend.php", this.attr('value'), (transport) => { + try { + Notify.close(); + dialog.hide(); - const data = JSON.parse(transport.responseText); + const data = JSON.parse(transport.responseText); - if (data) { - const id = data.id; + if (data) { + const id = data.id; - const tags = $("ATSTR-" + id); - const tooltip = dijit.byId("ATSTRTIP-" + id); + const tags = $("ATSTR-" + id); + const tooltip = dijit.byId("ATSTRTIP-" + id); - if (tags) tags.innerHTML = data.content; - if (tooltip) tooltip.attr('label', data.content_full); + if (tags) tags.innerHTML = data.content; + if (tooltip) tooltip.attr('label', data.content_full); + } + } catch (e) { + App.Error.report(e); } - } catch (e) { - App.Error.report(e); - } - }); - } - }, - href: query - }); + }); + } + }, + }); + + const tmph = dojo.connect(dialog, 'onLoad', function () { + dojo.disconnect(tmph); + + new Ajax.Autocompleter('tags_str', 'tags_choices', + "backend.php?op=article&method=completeTags", + {tokens: ',', paramName: "search"}); + }); - const tmph = dojo.connect(dialog, 'onLoad', function () { - dojo.disconnect(tmph); + dialog.show(); - new Ajax.Autocompleter('tags_str', 'tags_choices', - "backend.php?op=article&method=completeTags", - {tokens: ',', paramName: "search"}); }); - dialog.show(); }, cdmMoveToId: function (id, params) { params = params || {}; -- cgit v1.2.3