toggleMark, togglePub: refactor implementation

shorten marked/published img CSS classes
master
Andrew Dolgov 6 years ago
parent 3325979bf0
commit a2ef54cd92

@ -331,11 +331,11 @@ class Feeds extends Handler_Protected {
$marked_pic_src = $line["marked"] ? "mark_set.png" : "mark_unset.png";
$class .= $line["marked"] ? " marked" : "";
$marked_pic = "<img src=\"images/$marked_pic_src\" class=\"markedPic\" onclick='toggleMark($id)'>";
$marked_pic = "<img src=\"images/$marked_pic_src\" class=\"marked-pic marked-$id\" onclick='toggleMark($id)'>";
$published_pic_src = $line["published"] ? "pub_set.png" : "pub_unset.png";
$class .= $line["published"] ? " published" : "";
$published_pic = "<img src=\"images/$published_pic_src\" class=\"pubPic\" onclick='togglePub($id)'>";
$published_pic = "<img src=\"images/$published_pic_src\" class=\"pub-pic pub-$id\" onclick='togglePub($id)'>";
$updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
$date_entered_fmt = T_sprintf("Imported at %s",

@ -425,7 +425,7 @@ class Pref_Users extends Handler_Protected {
$onclick = "onclick='editUser($uid, event)' title='".__('Click to edit')."'";
print "<td $onclick><img src='images/user.png' class='markedPic' alt=''> " . $line["login"] . "</td>";
print "<td $onclick><img src='images/user.png' class='marked-pic' alt=''> " . $line["login"] . "</td>";
if (!$line["email"]) $line["email"] = "&nbsp;";

File diff suppressed because one or more lines are too long

@ -561,14 +561,14 @@ body.ttrss_main {
border-radius : 4px;
}
img.markedPic, img.pubPic {
img.marked-pic, img.pub-pic {
cursor : pointer;
vertical-align : middle;
opacity : 0.5;
transition : opacity 0.25s;
}
img.markedPic:hover, img.pubPic:hover {
img.marked-pic:hover, img.pub-pic:hover {
opacity : 1;
}

@ -26,7 +26,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
if (this.model.store.getValue(args.item, 'id') != 'root') {
const img = dojo.doc.createElement('img');
img.src ='images/filter.png';
img.className = 'markedPic';
img.className = 'marked-pic';
tnode._filterIconNode = img;
domConstruct.place(tnode._filterIconNode, tnode.labelNode, 'before');
}

@ -400,93 +400,64 @@ function toggleMark(id, client_only) {
const query = { op: "rpc", id: id, method: "mark" };
const row = $("RROW-" + id);
if (!row) return;
const imgs = [];
const row_imgs = row.getElementsByClassName("markedPic");
for (let i = 0; i < row_imgs.length; i++)
imgs.push(row_imgs[i]);
const ft = $("floatingTitle");
if (ft && ft.getAttribute("data-article-id") == id) {
const fte = ft.getElementsByClassName("markedPic");
for (var i = 0; i < fte.length; i++)
imgs.push(fte[i]);
}
for (i = 0; i < imgs.length; i++) {
const img = imgs[i];
if (row) {
const imgs = $$("img[class*=marked-pic][class*=marked-" + id + "]");
if (!row.hasClassName("marked")) {
img.src = img.src.replace("mark_unset", "mark_set");
query.mark = 1;
} else {
img.src = img.src.replace("mark_set", "mark_unset");
query.mark = 0;
}
}
imgs.each((img) => {
if (!row.hasClassName("marked")) {
img.src = img.src.replace("mark_unset", "mark_set");
query.mark = 1;
} else {
img.src = img.src.replace("mark_set", "mark_unset");
query.mark = 0;
}
});
row.toggleClassName("marked");
row.toggleClassName("marked");
if (!client_only)
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
if (!client_only)
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
}
}
function togglePub(id, client_only, no_effects, note) {
const query = { op: "rpc", id: id, method: "publ" };
if (note != undefined) {
query.note = note;
} else {
query.note = "undefined";
}
const row = $("RROW-" + id);
if (!row) return;
const imgs = [];
const row_imgs = row.getElementsByClassName("pubPic");
for (let i = 0; i < row_imgs.length; i++)
imgs.push(row_imgs[i]);
if (row) {
if (note != undefined) {
query.note = note;
} else {
query.note = "undefined";
}
const ft = $("floatingTitle");
const imgs = $$("img[class*=pub-pic][class*=pub-" + id + "]");
if (ft && ft.getAttribute("data-article-id") == id) {
const fte = ft.getElementsByClassName("pubPic");
imgs.each((img) => {
if (!row.hasClassName("published") || note != undefined) {
img.src = img.src.replace("pub_unset", "pub_set");
query.pub = 1;
} else {
img.src = img.src.replace("pub_set", "pub_unset");
query.pub = 0;
}
});
for (let i = 0; i < fte.length; i++)
imgs.push(fte[i]);
}
if (note != undefined)
row.addClassName("published");
else
row.toggleClassName("published");
for (let i = 0; i < imgs.length; i++) {
const img = imgs[i];
if (!client_only)
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
if (!row.hasClassName("published") || note != undefined) {
img.src = img.src.replace("pub_unset", "pub_set");
query.pub = 1;
} else {
img.src = img.src.replace("pub_set", "pub_unset");
query.pub = 0;
}
}
if (note != undefined)
row.addClassName("published");
else
row.toggleClassName("published");
if (!client_only)
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
}
function moveToPost(mode, noscroll, noexpand) {
@ -1932,7 +1903,7 @@ function updateFloatingTitle(unread_only) {
$("floatingTitle").setAttribute("data-article-id", child.getAttribute("data-article-id"));
$("floatingTitle").innerHTML = header.innerHTML;
$("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('" + child.id + "')\">" + $("floatingTitle").firstChild.innerHTML;
$("floatingTitle").firstChild.innerHTML = "<img class='anchor marked-pics' src='images/page_white_go.png' onclick=\"scrollToRowId('" + child.id + "')\">" + $("floatingTitle").firstChild.innerHTML;
initFloatingMenu();

@ -22,12 +22,12 @@ class Mark_Button extends Plugin {
if (sql_bool_to_bool($line["marked"])) {
$marked_pic = "<img
src=\"images/mark_set.png\"
class=\"markedPic\" alt=\"Unstar article\"
class=\"marked-pic marked-$id\" alt=\"Unstar article\"
onclick='toggleMark($id)'>";
} else {
$marked_pic = "<img
src=\"images/mark_unset.png\"
class=\"markedPic\" alt=\"Star article\"
class=\"marked-pic marked-$id\" alt=\"Star article\"
onclick='toggleMark($id)'>";
}
}

Loading…
Cancel
Save