editarticletags: load dialog via XHR

master
Andrew Dolgov 2 years ago
parent 0706a328a4
commit 42b5564d1e
  1. 6
      classes/article.php
  2. 71
      js/Article.js

@ -1,12 +1,6 @@
<?php
class Article extends Handler_Protected {
function csrf_ignore($method) {
$csrf_ignored = array("editarticletags");
return array_search($method, $csrf_ignored) !== false;
}
function redirect() {
$id = clean($_REQUEST['id']);

@ -257,53 +257,56 @@ const Article = {
return false;
},
editTags: function (id) {
const query = "backend.php?op=article&method=editArticleTags&param=" + 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 || {};

Loading…
Cancel
Save