properly handle on-the-fly adding of categories
This commit is contained in:
parent
10249c41b7
commit
c00907f2ed
20
functions.js
20
functions.js
|
@ -2166,7 +2166,7 @@ function catSelectOnChange(elem) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function quickAddCat(select) {
|
function quickAddCat(elem) {
|
||||||
try {
|
try {
|
||||||
var cat = prompt(__("Please enter category title:"));
|
var cat = prompt(__("Please enter category title:"));
|
||||||
|
|
||||||
|
@ -2174,15 +2174,18 @@ function quickAddCat(select) {
|
||||||
|
|
||||||
var query = "?op=rpc&subop=quickAddCat&cat=" + param_escape(cat);
|
var query = "?op=rpc&subop=quickAddCat&cat=" + param_escape(cat);
|
||||||
|
|
||||||
|
notify_progress("Loading, please wait...", true);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function (transport) {
|
onComplete: function (transport) {
|
||||||
var response = transport.responseXML;
|
var response = transport.responseXML;
|
||||||
|
var select = response.getElementsByTagName("select")[0];
|
||||||
|
var options = select.getElementsByTagName("option");
|
||||||
|
|
||||||
var payload = response.getElementsByTagName("payload")[0];
|
dropbox_replace_options(elem, options);
|
||||||
|
|
||||||
if (payload)
|
notify('');
|
||||||
select.innerHTML = payload.firstChild.nodeValue;
|
|
||||||
|
|
||||||
} });
|
} });
|
||||||
|
|
||||||
|
@ -2283,7 +2286,14 @@ function dropbox_replace_options(elem, options) {
|
||||||
var text = options[i].firstChild.nodeValue;
|
var text = options[i].firstChild.nodeValue;
|
||||||
var value = options[i].getAttribute("value");
|
var value = options[i].getAttribute("value");
|
||||||
var issel = options[i].getAttribute("selected") == "1";
|
var issel = options[i].getAttribute("selected") == "1";
|
||||||
elem.insert(new Option(text, value, issel));
|
|
||||||
|
var option = new Option(text, value, issel);
|
||||||
|
|
||||||
|
if (options[i].getAttribute("disabled"))
|
||||||
|
option.setAttribute("disabled", true);
|
||||||
|
|
||||||
|
elem.insert(option);
|
||||||
|
|
||||||
if (issel) sel_idx = i;
|
if (issel) sel_idx = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3047,17 +3047,19 @@
|
||||||
WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
|
WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
|
||||||
|
|
||||||
if (db_num_rows($result) > 0 && $include_all_cats) {
|
if (db_num_rows($result) > 0 && $include_all_cats) {
|
||||||
print "<option disabled>--------</option>";
|
print "<option disabled=\"1\">--------</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
if ($line["id"] == $default_id) {
|
if ($line["id"] == $default_id) {
|
||||||
$is_selected = "selected=\"1\"";
|
$is_selected = "selected=\"1\"";
|
||||||
} else {
|
} else {
|
||||||
$is_selected = "";
|
$is_selected = "";
|
||||||
}
|
}
|
||||||
printf("<option $is_selected value='%d'>%s</option>",
|
|
||||||
$line["id"], htmlspecialchars($line["title"]));
|
if ($line["title"])
|
||||||
|
printf("<option $is_selected value='%d'>%s</option>",
|
||||||
|
$line["id"], htmlspecialchars($line["title"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<option value=\"ADD_CAT\">" .__("Add category...") . "</option>";
|
print "<option value=\"ADD_CAT\">" .__("Add category...") . "</option>";
|
||||||
|
@ -6609,6 +6611,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_feed_category($link, $feed_cat) {
|
function add_feed_category($link, $feed_cat) {
|
||||||
|
|
||||||
|
if (!$feed_cat) return false;
|
||||||
|
|
||||||
db_query($link, "BEGIN");
|
db_query($link, "BEGIN");
|
||||||
|
|
||||||
$result = db_query($link,
|
$result = db_query($link,
|
||||||
|
|
|
@ -1108,9 +1108,7 @@
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<payload><![CDATA[";
|
|
||||||
print_feed_cat_select($link, "cat_id", $id);
|
print_feed_cat_select($link, "cat_id", $id);
|
||||||
print "]]></payload>";
|
|
||||||
|
|
||||||
print "</rpc-reply>";
|
print "</rpc-reply>";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue