]> git.wh0rd.org Git - tt-rss.git/commitdiff
misc code cleanup, allow ctrl-key selection in prefs
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 11 Nov 2010 15:59:21 +0000 (18:59 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 11 Nov 2010 15:59:21 +0000 (18:59 +0300)
modules/popup-dialog.php
modules/pref-feeds.php
modules/pref-filters.php
modules/pref-labels.php
modules/pref-users.php
prefs.js

index 520c9f95477a74e01bbc67db76379ad4b5ba5742..364dfe7b023021d66b6245b41a0ef484f1302263 100644 (file)
@@ -80,8 +80,8 @@
                                WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
 
                        print   __('Select:')." 
-                               <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
-                               <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
+                               <a href=\"#\" onclick=\"selectPrefRows('fcat', true)\">".__('All')."</a>,
+                               <a href=\"#\" onclick=\"selectPrefRows('fcat', false)\">".__('None')."</a>";
 
                        print "<div class=\"prefFeedCatHolder\">";
 
@@ -93,7 +93,7 @@
                        print "<tr class=\"odd\" id=\"FCATR-0\">";
 
                        print "<td width='5%' align='center'><input 
-                               onclick='toggleSelectPrefRow(this, \"fcat\");' 
+                               onclick='toggleSelectRow(this);' 
                                type=\"checkbox\" id=\"FCCHK-0\"></td>";
 
                        if (!$_SESSION["profile"]) {
                                $edit_title = htmlspecialchars($line["title"]);
        
                                print "<td width='5%' align='center'><input 
-                                       onclick='toggleSelectPrefRow(this, \"fcat\");' 
+                                       onclick='toggleSelectRow(this);' 
                                        type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
 
                                if ($_SESSION["profile"] == $line["id"]) {
index d83a1a25b54f5fa9ea8c633d245ad9fb98a12139..e557903ea8c57449dcff9ceda1be70c785b50fec 100644 (file)
                                <input id=\"fadd_cat\" 
                                        onkeypress=\"return filterCR(event, addFeedCat)\"
                                        size=\"40\">
-                                       <button onclick=\"javascript:addFeedCat()\">".
+                                       <button onclick=\"addFeedCat()\">".
                                        __('Create category')."</button></div>";
        
                        $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
                        if (db_num_rows($result) != 0) {
 
                                print   __('Select:')." 
-                                       <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
-                                       <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
+                                       <a href=\"#\" onclick=\"selectPrefRows('fcat', true)\">".__('All')."</a>,
+                                       <a href=\"#\" onclick=\"selectPrefRows('fcat', false)\">".__('None')."</a>";
 
                                print "<div class=\"prefFeedCatHolder\">";
 
                                        $edit_title = htmlspecialchars($line["title"]);
                
                                        print "<td width='5%' align='center'><input 
-                                               onclick='toggleSelectPrefRow(this, \"fcat\");' 
+                                               onclick='toggleSelectRow(this);' 
                                                type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
        
                                        print "<td><span id=\"FCATT-$cat_id\">" . 
 
                print "<div style='float : right'> 
                        <input id=\"feed_search\" size=\"20\" type=\"search\"
-                               onfocus=\"javascript:disableHotkeys();\" 
-                               onblur=\"javascript:enableHotkeys();\"
-                               onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
-                       <button onclick=\"javascript:updateFeedList()\">".
+                               onfocus=\"disableHotkeys();\" 
+                               onblur=\"enableHotkeys();\"
+                               onchange=\"updateFeedList()\" value=\"$feed_search\">
+                       <button onclick=\"updateFeedList()\">".
                                __('Search')."</button>
                        </div>";
                
 
                if (get_pref($link, 'ENABLE_FEED_CATS')) {
 
-                       print "<button onclick=\"javascript:editFeedCats()\">".
+                       print "<button onclick=\"editFeedCats()\">".
                                __('Edit categories')."</button> ";
                }
 
-               print "<button onclick=\"javascript:removeSelectedFeeds()\">"
+               print "<button onclick=\"removeSelectedFeeds()\">"
                        .__('Unsubscribe')."</button> ";
 
                if (defined('_ENABLE_FEED_DEBUGGING')) {
                                $show_last_article_checked><label 
                                        for='show_last_article_times'>".__('Show last article times')."</label></div>".
                                __('Select:')."
-                                       <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>,
-                                       <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a>
+                                       <a href=\"#\" onclick=\"selectPrefRows('feed', true)\">".__('All')."</a>,
+                                       <a href=\"#\" onclick=\"selectPrefRows('feed', false)\">".__('None')."</a>
                                </td</tr>";
 
                        if (!get_pref($link, 'ENABLE_FEED_CATS')) {
 
                                print "<td width='3%'>&nbsp;</td>";
 
-                               print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
+                               print "<td width='60%'><a href=\"#\" onclick=\"updateFeedList('title')\">".__('Title')."</a></td>";
 
                                if ($show_last_article_info) {
-                                       print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
+                                       print "<td width='20%' align='right'><a href=\"#\" onclick=\"updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
                                }
 
-                               print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
+                               print "<td width='20%' align='right'><a href=\"#\" onclick=\"updateFeedList('last_updated')\">".__('Updated')."</a></td>";
                        }
                        
                        $lnum = 0;
 
                                        print "<td width='3%'>&nbsp;</td>";
 
-                                       print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
+                                       print "<td width='60%'><a href=\"#\" onclick=\"updateFeedList('title')\">".__('Title')."</a></td>";
 
                                        if ($show_last_article_info) {
                                                print "<td width='20%' align='right'>
-                                                       <a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
+                                                       <a href=\"#\" onclick=\"updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
                                        }
 
                                        print "<td width='20%' align='right'>
-                                               <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
+                                               <a href=\"#\" onclick=\"updateFeedList('last_updated')\">".__('Updated')."</a></td>";
 
                                        $cur_cat_id = $cat_id;
                                }
                                        $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
                                }
                                
-                               print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");' 
+                               print "<td class='feedSelect'><input onclick='toggleSelecRow(this);' 
                                type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
 
-                               $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'";
+                               $onclick = "onclick='editFeed($feed_id, event)' title='".__('Click to edit')."'";
 
                                print "<td $onclick class='feedIcon'>$feed_icon</td>";          
 
index 26efebd507c7dafefbb450602e9614b48b239e59..5df8a8cea53e8cd90ae10114bb959bab8a3cd7aa 100644 (file)
 
                        print "<tr><td class=\"selectPrompt\" colspan=\"8\">
                                ".__('Select:')." 
-                                       <a href=\"javascript:selectPrefRows('filter', true)\">".__('All')."</a>,
-                                       <a href=\"javascript:selectPrefRows('filter', false)\">".__('None')."</a>
+                                       <a href=\"#\" onclick=\"selectPrefRows('filter', true)\">".__('All')."</a>,
+                                       <a href=\"#\" onclick=\"selectPrefRows('filter', false)\">".__('None')."</a>
                                </td</tr>";
 
                        $lnum = 0;
 
                                        print "<tr class=\"title\">
                                                <td align='center' width=\"5%\">&nbsp;</td>
-                                               <td width=\"20%\"><a href=\"javascript:updateFilterList('reg_exp')\">".__('Match')."</a></td>
-                                               <td width=\"\"><a href=\"javascript:updateFilterList('feed_title')\">".__('Feed')."</a></td>
-                                               <td width=\"20%\"><a href=\"javascript:updateFilterList('filter_type')\">".__('Field')."</a></td>
-                                               <td width=\"20%\"><a href=\"javascript:updateFilterList('action_param')\">".__('Params')."</a></td>"; 
+                                               <td width=\"20%\"><a href=\"#\" onclick=\"updateFilterList('reg_exp')\">".__('Match')."</a></td>
+                                               <td width=\"\"><a href=\"#\" onclick=\"updateFilterList('feed_title')\">".__('Feed')."</a></td>
+                                               <td width=\"20%\"><a href=\"#\" onclick=\"updateFilterList('filter_type')\">".__('Field')."</a></td>
+                                               <td width=\"20%\"><a href=\"#\" onclick=\"updateFilterList('action_param')\">".__('Params')."</a></td>"; 
 
                                        $lnum = 0;
                                }
 
                                $line["feed_title"] = htmlspecialchars($line["feed_title"]);
 
-                               print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"filter\");' 
+                               print "<td align='center'><input onclick='toggleSelectRow(this);' 
                                        type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
 
                                $filter_params = array(
                                                $line["action_param"] . "</span>";
                                }       
 
-                               $onclick = "onclick='editFilter($filter_id)' title='".__('Click to edit')."'";
+                               $onclick = "onclick='editFilter($filter_id, event)' title='".__('Click to edit')."'";
 
                                $inverse_label = "";
 
index 884a25d1a5d217b65f853434dd1b133ffa34187f..d7a300843dac804912bbb3e5a293f325734bada6 100644 (file)
 
                        print "<tr><td class=\"selectPrompt\" colspan=\"8\">
                                ".__('Select:')." 
-                                       <a href=\"javascript:selectPrefRows('label', true)\">".__('All')."</a>,
-                                       <a href=\"javascript:selectPrefRows('label', false)\">".__('None')."</a>
+                                       <a href=\"#\" onclick=\"selectPrefRows('label', true)\">".__('All')."</a>,
+                                       <a href=\"#\" onclick=\"selectPrefRows('label', false)\">".__('None')."</a>
                                </td</tr>";
 
 /*                     print "<tr class=\"title\">
                                if (!$bg_color) $bg_color = "";
 
                                print "<td width='5%' align='center'><input 
-                                       onclick='toggleSelectPrefRow(this, \"label\");' 
+                                       onclick='toggleSelectRow(this);' 
                                        type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
        
                                $id = $line['id'];
index a4531c45f196ba9c0ee40c640defe46939813492..dcca9a9366d60b4f51698a65a21787ef74aac6ee 100644 (file)
 
                print "<tr><td class=\"selectPrompt\" colspan=\"8\">
                                ".__('Select:')." 
-                                       <a href=\"javascript:selectPrefRows('user', true)\">".__('All')."</a>,
-                                       <a href=\"javascript:selectPrefRows('user', false)\">".__('None')."</a>
+                                       <a href=\"#\" onclick=\"selectPrefRows('user', true)\">".__('All')."</a>,
+                                       <a href=\"#\" onclick=\"selectPrefRows('user', false)\">".__('None')."</a>
                                </td</tr>";
 
                print "<tr class=\"title\">
                                        <td align='center' width=\"5%\">&nbsp;</td>
-                                       <td width=''><a href=\"javascript:updateUsersList('login')\">".__('Login')."</a></td>
-                                       <td width='20%'><a href=\"javascript:updateUsersList('access_level')\">".__('Access Level')."</a></td>
-                                       <td width='20%'><a href=\"javascript:updateUsersList('created')\">".__('Registered')."</a></td>
-                                       <td width='20%'><a href=\"javascript:updateUsersList('last_login')\">".__('Last login')."</a></td></tr>";
+                                       <td width=''><a href=\"#\" onclick=\"updateUsersList('login')\">".__('Login')."</a></td>
+                                       <td width='20%'><a href=\"#\" onclick=\"updateUsersList('access_level')\">".__('Access Level')."</a></td>
+                                       <td width='20%'><a href=\"#\" onclick=\"updateUsersList('created')\">".__('Registered')."</a></td>
+                                       <td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_login')\">".__('Last login')."</a></td></tr>";
                
                $lnum = 0;
                
                        $line["created"] = make_local_datetime($link, $line["created"], false);
                        $line["last_login"] = make_local_datetime($link, $line["last_login"], false);
 
-                       print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"user\");' 
+                       print "<td align='center'><input onclick='toggleSelectRow(this);' 
                                type=\"checkbox\" id=\"UMCHK-$uid\"></td>";
 
-                       $onclick = "onclick='editUser($uid)' title='".__('Click to edit')."'";
+                       $onclick = "onclick='editUser($uid, event)' title='".__('Click to edit')."'";
 
                        print "<td $onclick>" . $line["login"] . "</td>";               
 
index 2d8b02942e7e47ed92c9d896ee530cfbba902f2e..4740686efa57238a8a0193d186ca988593620750 100644 (file)
--- 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 {