]> git.wh0rd.org Git - tt-rss.git/commitdiff
disable some submit-type buttons when required data is not given
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 18 May 2006 08:29:17 +0000 (09:29 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 18 May 2006 08:29:17 +0000 (09:29 +0100)
backend.php
functions.js
prefs.js
tt-rss.js

index be7aba382e6c80fe3c81d2aa4c54ef41f02d0b0e..66d52ae9e92f9467c0b6195a8abd678219ecb0e1 100644 (file)
                        cellspacing='0' cellpadding='0'><tr>
                        <td>
                                <input id=\"fadd_link\" 
-                               onchange=\"javascript:addFeed()\"
-                               size=\"40\">
+                                       onchange=\"javascript:addFeed()\"
+                                       onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
+                                       size=\"40\">
                                <input type=\"submit\" class=\"button\"
-                               onclick=\"javascript:addFeed()\" value=\"Subscribe\">";
+                                       disabled=\"true\" id=\"fadd_submit_btn\"
+                                       onclick=\"addFeed()\" value=\"Subscribe\">";
 
                if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) {
                        print " <input type=\"submit\" class=\"button\"
                
                print "</td><td align='right'>
                                <input id=\"feed_search\" size=\"20\"  
-                               onchange=\"javascript:updateFeedList()\"
-                               value=\"$feed_search\">
+                                       onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
                                <input type=\"submit\" class=\"button\" 
                                onclick=\"javascript:updateFeedList()\" value=\"Search\">
                        </td>                   
                }
 
                print "<div class=\"prefGenericAddBox\">
-                       <input size=\"40\" id=\"ladd_expr\">&nbsp;";
+                       <input size=\"40\"                      
+                               onkeyup=\"toggleSubmitNotEmpty(this, 'label_create_btn')\"
+                               id=\"ladd_expr\">&nbsp;";
                        
                print"<input type=\"submit\" class=\"button\" 
-                       onclick=\"javascript:addLabel()\" value=\"Add label\"></div>";
+                       disabled=\"true\" id=\"label_create_btn\"
+                       onclick=\"javascript:addLabel()\" value=\"Create label\"></div>";
 
                $result = db_query($link, "SELECT 
                                id,sql_exp,description
                        print "<table width='100%'>
                        <tr><td>Feed URL:</td><td>
                                <input onblur=\"javascript:enableHotkeys()\" 
+                                       onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
                                        onfocus=\"javascript:disableHotkeys()\" id=\"qafInput\"></td></tr>";
                
                        if (get_pref($link, 'ENABLE_FEED_CATS')) {
                                print "</td></tr>";
                        }
                        
-                       print "<tr><td colspan='2' align='right'><input class=\"button\"
-                               type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Subscribe\">
-                       <input class=\"button\"
-                               type=\"submit\" onclick=\"javascript:closeInfoBox()\" 
-                               value=\"Cancel\"></td></tr></table>";
+                       print "<tr><td colspan='2' align='right'>
+                               <input class=\"button\"
+                                       id=\"fadd_submit_btn\" disabled=\"true\"
+                                       type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Subscribe\">
+                               <input class=\"button\"
+                                       type=\"submit\" onclick=\"javascript:closeInfoBox()\" 
+                                       value=\"Cancel\"></td></tr></table>";
                }
 
                if ($id == "quickDelFeed") {
                        print "<table width='100%'><tr><td>Search:</td><td>";
 
                        print "<input id=\"searchbox\" class=\"extSearch\"                      
-                       onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
-                       onchange=\"javascript:search()\">
+                               onblur=\"javascript:enableHotkeys()\" 
+                               onfocus=\"javascript:disableHotkeys()\"
+                               onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
+                               onchange=\"javascript:search()\">                               
                        </td></tr><tr><td>Where:</td><td>
                        <select id=\"searchmodebox\">
                                <option selected>All feeds</option>";
 
                        <tr><td colspan='2' align='right'>
                        <input type=\"submit\" 
-                               class=\"button\" onclick=\"javascript:search()\" value=\"Search\">
+                               class=\"button\" onclick=\"javascript:search()\" 
+                               id=\"search_submit_btn\" disabled=\"true\"
+                               value=\"Search\">
                        <input class=\"button\"
                                type=\"submit\" onclick=\"javascript:closeInfoBox()\" 
                                value=\"Cancel\"></td></tr></table>";
 
                        print "<table width='100%'>";
 
-                       print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"30\">&nbsp;";
+                       print "<tr><td>Match:</td>
+                               <td><input onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
+                               id=\"fadd_regexp\" size=\"30\">&nbsp;";
                        
                        print_select("fadd_match", "Title", $filter_types);     
        
                        print "</td></tr><tr><td colspan=\"2\" align=\"right\">";
        
                        print "<input type=\"submit\" 
+                               id=\"infobox_submit\"
                                class=\"button\" onclick=\"javascript:qaddFilter()\" 
-                               value=\"Create\"> ";
+                               disabled=\"true\" value=\"Create\"> ";
 
                        print "<input class=\"button\"
                                type=\"submit\" onclick=\"javascript:closeInfoBox()\" 
                }
 
                print "<div class=\"prefGenericAddBox\">
-                       <input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\">&nbsp;";
+                       <input id=\"uadd_box\"                  
+                               onkeyup=\"toggleSubmitNotEmpty(this, 'user_add_btn')\"
+                               onchange=\"javascript:addUser()\" size=\"40\">&nbsp;";
                        
                print"<input type=\"submit\" class=\"button\" 
-                       onclick=\"javascript:addUser()\" value=\"Add user\"></div>";
+                       id=\"user_add_btn\" disabled=\"true\"
+                       onclick=\"javascript:addUser()\" value=\"Create user\"></div>";
 
                $result = db_query($link, "SELECT 
                                id,login,access_level,email,
index d5ac2c087f79bf55f5ff8897207b13aefbdb6f22..6b064b2f0f84f6db852ae70cf3b821ddc02c8c3f 100644 (file)
@@ -947,6 +947,7 @@ function displayDlg(id, param) {
        xmlhttp.send(null);
 
        disableHotkeys();
+
 }
 
 function infobox_submit_callback() {
@@ -1009,4 +1010,10 @@ function qaddFilter() {
 
 }
 
-
+function toggleSubmitNotEmpty(e, submit_id) {
+       try {
+               document.getElementById(submit_id).disabled = (e.value == "")
+       } catch (e) {
+               exception_error("toggleSubmitNotEmpty", e);
+       }
+}
index 2539c3b629623c76863bace525f0fd35ae6f2188..8622526dd22ac6e71eafb895f3932a1114f8da2f 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -282,6 +282,9 @@ function addFeed() {
 
        if (link.value.length == 0) {
                alert("Error: No feed URL given.");
+       } else if (link.value.match("http://") == null && 
+                       link.value.match("https://") == null) {
+               alert("Error: Invalid feed URL.");
        } else {
                notify("Adding feed...");
 
index f3f496b185c24c888ac27c4db13cf4ee0bb1b1f7..82a52e9424eebd7f4e4f8b2d0da71fc59d7a3935 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -535,9 +535,14 @@ function qafAdd() {
 
        if (link.value.length == 0) {
                alert("Error: No feed URL given.");
+       } else if (link.value.match("http://") == null && 
+                       link.value.match("https://") == null) {
+               alert("Error: Invalid feed URL.");
        } else {
                notify("Adding feed...");
-       
+
+               closeInfoBox();
+
                var cat = document.getElementById("qafCat");
                var cat_id = "";