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.

andybradford 2013-12-17 03:46 hidden-tag
Commit bb6ba17b371a4bc41118538d99bbd5bca6fe0e12
1 file changed +9 -3
+9 -3
--- src/info.c
+++ src/info.c
@@ -2208,26 +2208,32 @@
22082208
style_header("Edit Check-in [%s]", zUuid);
22092209
/*
22102210
** Javascript functions to assist in modifying hidden branch options.
22112211
** chgcbn/chgbn: Handle change of (checkbox for) branch name in
22122212
** 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.
22132216
*/
22142217
@ <script>
22152218
@ function chgcbn(checked, branch){
22162219
@ val = gebi('brname').value;
2217
- @ if( !val || !checked) val = branch;
2220
+ @ if( !val || !checked ) val = branch;
22182221
@ gebi('hbranch').textContent = val;
22192222
@ cidbrid = document.getElementById('cbranch');
22202223
@ if( cidbrid ) cidbrid.textContent = val;
22212224
@ }
22222225
@ function chgbn(val, branch){
2223
- @ if( !val ) val = branch;
2226
+ @ if( isempty(val) ) val = branch;
22242227
@ gebi('newbr').checked = (val!=branch);
22252228
@ gebi('hbranch').textContent = val;
22262229
@ cidbrid = document.getElementById('cbranch');
22272230
@ if( cidbrid ) cidbrid.textContent = val;
22282231
@ }
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 = ''; }
22292235
@ </script>
22302236
if( P("preview") ){
22312237
Blob suffix;
22322238
int nTag = 0;
22332239
@ <b>Preview:</b>
@@ -2358,11 +2364,11 @@
23582364
@ <td valign="top">
23592365
@ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
23602366
@ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
23612367
@ Make this check-in the start of a new branch named:</label>
23622368
@ <input id="brname" type="text" style="width:15;" name="brname"
2363
- @ value="%h(zNewBranch)"
2369
+ @ value="%h(zNewBranch)" onblur="defifempty(this)" onfocus="clrifsame(this)"
23642370
@ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
23652371
if( !fHasHidden ){
23662372
@ <tr><th align="right" valign="top">Branch Hiding:</th>
23672373
@ <td valign="top">
23682374
@ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
23692375
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button