Skip to content

Commit

Permalink
Use placeholder attribute for stopwatch input fields
Browse files Browse the repository at this point in the history
As part of issue #11826 to remove all inline JavaScript, the time
tracking stopwatch feature was rewritten using jQuery. A default value
of "hh:mm" was being placed in the time tracking input field which is
invalid if submitted.

We should be using the newer 'placeholder' HTML attribute instead of
mangling the actual value stored in the text input field.
  • Loading branch information
davidhicks committed Jul 15, 2011
1 parent 28eb1f9 commit 10af3a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bug_change_status_page.php
Expand Up @@ -362,7 +362,7 @@
<?php echo lang_get( 'time_tracking' ) ?>
</th>
<td>
<input type="text" name="time_tracking" size="5" value="hh:mm" />
<input type="text" name="time_tracking" size="5" placeholder="hh:mm" />
</td>
</tr>
<?php } ?>
Expand Down
4 changes: 2 additions & 2 deletions bugnote_add_inc.php
Expand Up @@ -104,11 +104,11 @@
</th>
<td>
<?php if ( config_get( 'time_tracking_stopwatch' ) && config_get( 'use_javascript' ) ) { ?>
<input type="text" name="time_tracking" class="stopwatch_time" size="8" value="hh:mm:ss" />
<input type="text" name="time_tracking" class="stopwatch_time" size="8" placeholder="hh:mm:ss" />
<input type="button" name="time_tracking_toggle" class="stopwatch_toggle" value="<?php echo lang_get( 'time_tracking_stopwatch_start' ) ?>" />
<input type="button" name="time_tracking_reset" class="stopwatch_reset" value="<?php echo lang_get( 'time_tracking_stopwatch_reset' ) ?>" />
<?php } else { ?>
<input type="text" name="time_tracking" size="5" value="hh:mm" />
<input type="text" name="time_tracking" size="5" placeholder="hh:mm" />
<?php } ?>
</td>
</tr>
Expand Down
12 changes: 6 additions & 6 deletions javascript/common.js
Expand Up @@ -130,13 +130,13 @@ $(document).ready( function() {
if (hours < 10) {
hours = '0' + hours;
}
$('input[type=text].stopwatch_time').attr('value', hours + ':' + minutes + ':' + seconds);
$('input[type=text].stopwatch_time').val(hours + ':' + minutes + ':' + seconds);
this.start();
},
reset: function() {
this.stop();
this.elapsedTime = 0;
$('input[type=text].stopwatch_time').attr('value', '00:00:00');
$('input[type=text].stopwatch_time').val('');
},
start: function() {
this.stop();
Expand All @@ -156,18 +156,18 @@ $(document).ready( function() {
if (stopwatch.elapsedTime == 0) {
stopwatch.stop();
stopwatch.start();
$('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_stop']);
$('input[type=button].stopwatch_toggle').val(translations['time_tracking_stopwatch_stop']);
} else if (typeof stopwatch.timerID == 'number') {
stopwatch.stop();
$('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_start']);
$('input[type=button].stopwatch_toggle').val(translations['time_tracking_stopwatch_start']);
} else {
stopwatch.start();
$('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_stop']);
$('input[type=button].stopwatch_toggle').val(translations['time_tracking_stopwatch_stop']);
}
});
$('input[type=button].stopwatch_reset').click(function() {
stopwatch.reset();
$('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_start']);
$('input[type=button].stopwatch_toggle').val(translations['time_tracking_stopwatch_start']);
});

$('input[type=text].datetime').each(function(index, element) {
Expand Down

0 comments on commit 10af3a5

Please sign in to comment.