From a998dbef95bb6ac94a0f4b401e94e4c932c855a0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 11 Nov 2010 18:59:21 +0300 Subject: [PATCH] misc code cleanup, allow ctrl-key selection in prefs --- modules/popup-dialog.php | 8 +-- modules/pref-feeds.php | 40 +++++------ modules/pref-filters.php | 16 ++--- modules/pref-labels.php | 6 +- modules/pref-users.php | 16 ++--- prefs.js | 147 +++++++++++++++------------------------ 6 files changed, 98 insertions(+), 135 deletions(-) diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 520c9f954..364dfe7b0 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -80,8 +80,8 @@ WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); print __('Select:')." - ".__('All').", - ".__('None').""; + ".__('All').", + ".__('None').""; print "
"; @@ -93,7 +93,7 @@ print ""; print ""; if (!$_SESSION["profile"]) { @@ -121,7 +121,7 @@ $edit_title = htmlspecialchars($line["title"]); print ""; if ($_SESSION["profile"] == $line["id"]) { diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index d83a1a25b..e557903ea 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -981,7 +981,7 @@ -
"; $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories @@ -993,8 +993,8 @@ if (db_num_rows($result) != 0) { print __('Select:')." - ".__('All').", - ".__('None').""; + ".__('All').", + ".__('None').""; print "
"; @@ -1017,7 +1017,7 @@ $edit_title = htmlspecialchars($line["title"]); print ""; print "" . @@ -1078,10 +1078,10 @@ print "
-
"; @@ -1093,11 +1093,11 @@ if (get_pref($link, 'ENABLE_FEED_CATS')) { - print " "; } - print " "; if (defined('_ENABLE_FEED_DEBUGGING')) { @@ -1199,8 +1199,8 @@ $show_last_article_checked>
". __('Select:')." - ".__('All').", - ".__('None')." + ".__('All').", + ".__('None')." "; if (!get_pref($link, 'ENABLE_FEED_CATS')) { @@ -1209,13 +1209,13 @@ print " "; - print "".__('Title').""; + print "".__('Title').""; if ($show_last_article_info) { - print "".__('Last Article').""; + print "".__('Last Article').""; } - print "".__('Updated').""; + print "".__('Updated').""; } $lnum = 0; @@ -1260,15 +1260,15 @@ print " "; - print "".__('Title').""; + print "".__('Title').""; if ($show_last_article_info) { print " - ".__('Last Article').""; + ".__('Last Article').""; } print " - ".__('Updated').""; + ".__('Updated').""; $cur_cat_id = $cat_id; } @@ -1286,10 +1286,10 @@ $feed_icon = ""; } - print ""; - $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'"; + $onclick = "onclick='editFeed($feed_id, event)' title='".__('Click to edit')."'"; print "$feed_icon"; diff --git a/modules/pref-filters.php b/modules/pref-filters.php index 26efebd50..5df8a8cea 100644 --- a/modules/pref-filters.php +++ b/modules/pref-filters.php @@ -377,8 +377,8 @@ print " ".__('Select:')." - ".__('All').", - ".__('None')." + ".__('All').", + ".__('None')." "; $lnum = 0; @@ -405,10 +405,10 @@ print "   - ".__('Match')." - ".__('Feed')." - ".__('Field')." - ".__('Params').""; + ".__('Match')." + ".__('Feed')." + ".__('Field')." + ".__('Params').""; $lnum = 0; } @@ -436,7 +436,7 @@ $line["feed_title"] = htmlspecialchars($line["feed_title"]); - print ""; $filter_params = array( @@ -486,7 +486,7 @@ $line["action_param"] . ""; } - $onclick = "onclick='editFilter($filter_id)' title='".__('Click to edit')."'"; + $onclick = "onclick='editFilter($filter_id, event)' title='".__('Click to edit')."'"; $inverse_label = ""; diff --git a/modules/pref-labels.php b/modules/pref-labels.php index 884a25d1a..d7a300843 100644 --- a/modules/pref-labels.php +++ b/modules/pref-labels.php @@ -208,8 +208,8 @@ print " ".__('Select:')." - ".__('All').", - ".__('None')." + ".__('All').", + ".__('None')." "; /* print " @@ -238,7 +238,7 @@ if (!$bg_color) $bg_color = ""; print ""; $id = $line['id']; diff --git a/modules/pref-users.php b/modules/pref-users.php index a4531c45f..dcca9a936 100644 --- a/modules/pref-users.php +++ b/modules/pref-users.php @@ -417,16 +417,16 @@ print " ".__('Select:')." - ".__('All').", - ".__('None')." + ".__('All').", + ".__('None')." "; print "   - ".__('Login')." - ".__('Access Level')." - ".__('Registered')." - ".__('Last login').""; + ".__('Login')." + ".__('Access Level')." + ".__('Registered')." + ".__('Last login').""; $lnum = 0; @@ -451,10 +451,10 @@ $line["created"] = make_local_datetime($link, $line["created"], false); $line["last_login"] = make_local_datetime($link, $line["last_login"], false); - print ""; - $onclick = "onclick='editUser($uid)' title='".__('Click to edit')."'"; + $onclick = "onclick='editUser($uid, event)' title='".__('Click to edit')."'"; print "" . $line["login"] . ""; diff --git a/prefs.js b/prefs.js index 2d8b02942..4740686ef 100644 --- a/prefs.js +++ b/prefs.js @@ -14,6 +14,8 @@ var mouse_is_down = false; var db = false; var store = false; +var seq = ""; + function feedlist_callback2(transport) { try { @@ -325,10 +327,12 @@ function addUser() { } } -function editUser(id) { +function editUser(id, event) { try { + if (!event || !event.ctrlKey) { + disableHotkeys(); notify_progress("Loading, please wait..."); @@ -346,58 +350,81 @@ function editUser(id) { document.forms['user_edit_form'].login.focus(); } }); + } else if (event.ctrlKey) { + var cb = $('UMCHK-' + id); + cb.checked = !cb.checked; + toggleSelectRow(cb); + } + } catch (e) { exception_error("editUser", e); } } -function editFilter(id) { +function editFilter(id, event) { try { - disableHotkeys(); + if (!event || !event.ctrlKey) { - notify_progress("Loading, please wait..."); + disableHotkeys(); - selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); - selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); + notify_progress("Loading, please wait..."); - var query = "?op=pref-filters&subop=edit&id=" + - param_escape(id); + selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); + selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); + + var query = "?op=pref-filters&subop=edit&id=" + + param_escape(id); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + infobox_callback2(transport); + document.forms['filter_edit_form'].reg_exp.focus(); + } }); + } else if (event.ctrlKey) { + var cb = $('FICHK-' + id); + cb.checked = !cb.checked; + toggleSelectRow(cb); + } - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - infobox_callback2(transport); - document.forms['filter_edit_form'].reg_exp.focus(); - } }); } catch (e) { exception_error("editFilter", e); } } -function editFeed(feed) { +function editFeed(feed, event) { try { - disableHotkeys(); + if (event && !event.ctrlKey) { + + disableHotkeys(); - notify_progress("Loading, please wait..."); + notify_progress("Loading, please wait..."); - // clean selection from all rows & select row being edited - selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); - selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); + // clean selection from all rows & select row being edited + selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); + selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); - var query = "?op=pref-feeds&subop=editfeed&id=" + - param_escape(feed); + var query = "?op=pref-feeds&subop=editfeed&id=" + + param_escape(feed); - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - infobox_callback2(transport); - document.forms["edit_feed_form"].title.focus(); - } }); + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + infobox_callback2(transport); + document.forms["edit_feed_form"].title.focus(); + } }); + + } else if (event.ctrlKey) { + var cb = $('FRCHK-' + feed); + cb.checked = !cb.checked; + toggleSelectRow(cb); + } + } catch (e) { exception_error("editFeed", e); @@ -1263,39 +1290,6 @@ function selectPrefRows(kind, select) { } -function toggleSelectPrefRow(sender, kind) { - - toggleSelectRow(sender); - - if (kind) { - var opbarid = false; - var nsel = -1; - - if (kind == "feed") { - opbarid = "feedOpToolbar"; - nsel = getSelectedFeeds(); - } else if (kind == "fcat") { - opbarid = "catOpToolbar"; - nsel = getSelectedFeedCats(); - } else if (kind == "filter") { - opbarid = "filterOpToolbar"; - nsel = getSelectedFilters(); - } else if (kind == "label") { - opbarid = "labelOpToolbar"; - nsel = getSelectedLabels(); - } else if (kind == "user") { - opbarid = "userOpToolbar"; - nsel = getSelectedUsers(); - } - - } -} - -function toggleSelectFBListRow(sender) { - toggleSelectListRow(sender); -} - -var seq = ""; function pref_hotkey_handler(e) { try { @@ -1794,37 +1788,6 @@ function removeFilter(id, title) { return false; } -/*function unsubscribeFeed(id, title) { - - try { - - var msg = __("Unsubscribe from %s?").replace("%s", title); - - var ok = confirm(msg); - - if (ok) { - closeInfoBox(); - - notify_progress("Removing feed..."); - - var query = "?op=pref-feeds&subop=remove&ids="+ - param_escape(id); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - feedlist_callback2(transport); - } }); - } - - } catch (e) { - exception_error("unsubscribeFeed", e); - } - - return false; - -} */ - function feedsEditSave() { try {