Fossil SCM
When editing a branch name, make the default value disappear when the input is entered. Also, strip whitespace from right-end of value and only update branch names if not all white space.
Commit
bb6ba17b371a4bc41118538d99bbd5bca6fe0e12
Parent
885d72b2bd59067…
1 file changed
+9
-3
+9
-3
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2208,26 +2208,32 @@ | ||
| 2208 | 2208 | style_header("Edit Check-in [%s]", zUuid); |
| 2209 | 2209 | /* |
| 2210 | 2210 | ** Javascript functions to assist in modifying hidden branch options. |
| 2211 | 2211 | ** chgcbn/chgbn: Handle change of (checkbox for) branch name in |
| 2212 | 2212 | ** remaining of form. |
| 2213 | + ** defifempty: return to default value if empty. | |
| 2214 | + ** clrifsame: clear the value if same as default. | |
| 2215 | + ** isempty: returns true if string has no non-whitespace characters. | |
| 2213 | 2216 | */ |
| 2214 | 2217 | @ <script> |
| 2215 | 2218 | @ function chgcbn(checked, branch){ |
| 2216 | 2219 | @ val = gebi('brname').value; |
| 2217 | - @ if( !val || !checked) val = branch; | |
| 2220 | + @ if( !val || !checked ) val = branch; | |
| 2218 | 2221 | @ gebi('hbranch').textContent = val; |
| 2219 | 2222 | @ cidbrid = document.getElementById('cbranch'); |
| 2220 | 2223 | @ if( cidbrid ) cidbrid.textContent = val; |
| 2221 | 2224 | @ } |
| 2222 | 2225 | @ function chgbn(val, branch){ |
| 2223 | - @ if( !val ) val = branch; | |
| 2226 | + @ if( isempty(val) ) val = branch; | |
| 2224 | 2227 | @ gebi('newbr').checked = (val!=branch); |
| 2225 | 2228 | @ gebi('hbranch').textContent = val; |
| 2226 | 2229 | @ cidbrid = document.getElementById('cbranch'); |
| 2227 | 2230 | @ if( cidbrid ) cidbrid.textContent = val; |
| 2228 | 2231 | @ } |
| 2232 | + @ function isempty(v){ s = v.replace(/\s+$/g,''); return(s == ''); } | |
| 2233 | + @ function defifempty(e){ if (isempty(e.value)) e.value = e.defaultValue; } | |
| 2234 | + @ function clrifsame(e){ if (e.value == e.defaultValue) e.value = ''; } | |
| 2229 | 2235 | @ </script> |
| 2230 | 2236 | if( P("preview") ){ |
| 2231 | 2237 | Blob suffix; |
| 2232 | 2238 | int nTag = 0; |
| 2233 | 2239 | @ <b>Preview:</b> |
| @@ -2358,11 +2364,11 @@ | ||
| 2358 | 2364 | @ <td valign="top"> |
| 2359 | 2365 | @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) |
| 2360 | 2366 | @ onchange="chgcbn(this.checked,'%h(zBranchName)')" /> |
| 2361 | 2367 | @ Make this check-in the start of a new branch named:</label> |
| 2362 | 2368 | @ <input id="brname" type="text" style="width:15;" name="brname" |
| 2363 | - @ value="%h(zNewBranch)" | |
| 2369 | + @ value="%h(zNewBranch)" onblur="defifempty(this)" onfocus="clrifsame(this)" | |
| 2364 | 2370 | @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr> |
| 2365 | 2371 | if( !fHasHidden ){ |
| 2366 | 2372 | @ <tr><th align="right" valign="top">Branch Hiding:</th> |
| 2367 | 2373 | @ <td valign="top"> |
| 2368 | 2374 | @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) /> |
| 2369 | 2375 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2208,26 +2208,32 @@ | |
| 2208 | style_header("Edit Check-in [%s]", zUuid); |
| 2209 | /* |
| 2210 | ** Javascript functions to assist in modifying hidden branch options. |
| 2211 | ** chgcbn/chgbn: Handle change of (checkbox for) branch name in |
| 2212 | ** remaining of form. |
| 2213 | */ |
| 2214 | @ <script> |
| 2215 | @ function chgcbn(checked, branch){ |
| 2216 | @ val = gebi('brname').value; |
| 2217 | @ if( !val || !checked) val = branch; |
| 2218 | @ gebi('hbranch').textContent = val; |
| 2219 | @ cidbrid = document.getElementById('cbranch'); |
| 2220 | @ if( cidbrid ) cidbrid.textContent = val; |
| 2221 | @ } |
| 2222 | @ function chgbn(val, branch){ |
| 2223 | @ if( !val ) val = branch; |
| 2224 | @ gebi('newbr').checked = (val!=branch); |
| 2225 | @ gebi('hbranch').textContent = val; |
| 2226 | @ cidbrid = document.getElementById('cbranch'); |
| 2227 | @ if( cidbrid ) cidbrid.textContent = val; |
| 2228 | @ } |
| 2229 | @ </script> |
| 2230 | if( P("preview") ){ |
| 2231 | Blob suffix; |
| 2232 | int nTag = 0; |
| 2233 | @ <b>Preview:</b> |
| @@ -2358,11 +2364,11 @@ | |
| 2358 | @ <td valign="top"> |
| 2359 | @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) |
| 2360 | @ onchange="chgcbn(this.checked,'%h(zBranchName)')" /> |
| 2361 | @ Make this check-in the start of a new branch named:</label> |
| 2362 | @ <input id="brname" type="text" style="width:15;" name="brname" |
| 2363 | @ value="%h(zNewBranch)" |
| 2364 | @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr> |
| 2365 | if( !fHasHidden ){ |
| 2366 | @ <tr><th align="right" valign="top">Branch Hiding:</th> |
| 2367 | @ <td valign="top"> |
| 2368 | @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) /> |
| 2369 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2208,26 +2208,32 @@ | |
| 2208 | style_header("Edit Check-in [%s]", zUuid); |
| 2209 | /* |
| 2210 | ** Javascript functions to assist in modifying hidden branch options. |
| 2211 | ** chgcbn/chgbn: Handle change of (checkbox for) branch name in |
| 2212 | ** remaining of form. |
| 2213 | ** defifempty: return to default value if empty. |
| 2214 | ** clrifsame: clear the value if same as default. |
| 2215 | ** isempty: returns true if string has no non-whitespace characters. |
| 2216 | */ |
| 2217 | @ <script> |
| 2218 | @ function chgcbn(checked, branch){ |
| 2219 | @ val = gebi('brname').value; |
| 2220 | @ if( !val || !checked ) val = branch; |
| 2221 | @ gebi('hbranch').textContent = val; |
| 2222 | @ cidbrid = document.getElementById('cbranch'); |
| 2223 | @ if( cidbrid ) cidbrid.textContent = val; |
| 2224 | @ } |
| 2225 | @ function chgbn(val, branch){ |
| 2226 | @ if( isempty(val) ) val = branch; |
| 2227 | @ gebi('newbr').checked = (val!=branch); |
| 2228 | @ gebi('hbranch').textContent = val; |
| 2229 | @ cidbrid = document.getElementById('cbranch'); |
| 2230 | @ if( cidbrid ) cidbrid.textContent = val; |
| 2231 | @ } |
| 2232 | @ function isempty(v){ s = v.replace(/\s+$/g,''); return(s == ''); } |
| 2233 | @ function defifempty(e){ if (isempty(e.value)) e.value = e.defaultValue; } |
| 2234 | @ function clrifsame(e){ if (e.value == e.defaultValue) e.value = ''; } |
| 2235 | @ </script> |
| 2236 | if( P("preview") ){ |
| 2237 | Blob suffix; |
| 2238 | int nTag = 0; |
| 2239 | @ <b>Preview:</b> |
| @@ -2358,11 +2364,11 @@ | |
| 2364 | @ <td valign="top"> |
| 2365 | @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) |
| 2366 | @ onchange="chgcbn(this.checked,'%h(zBranchName)')" /> |
| 2367 | @ Make this check-in the start of a new branch named:</label> |
| 2368 | @ <input id="brname" type="text" style="width:15;" name="brname" |
| 2369 | @ value="%h(zNewBranch)" onblur="defifempty(this)" onfocus="clrifsame(this)" |
| 2370 | @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr> |
| 2371 | if( !fHasHidden ){ |
| 2372 | @ <tr><th align="right" valign="top">Branch Hiding:</th> |
| 2373 | @ <td valign="top"> |
| 2374 | @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) /> |
| 2375 |