Skip to content

Commit

Permalink
Bug #11826 - Remove inline javascript for bug-jump field and put it i…
Browse files Browse the repository at this point in the history
…n common.js. Add

css styles for bug-jump.
  • Loading branch information
Daryn Warriner committed Aug 25, 2010
1 parent 6083666 commit e087425
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
11 changes: 4 additions & 7 deletions core/html_api.php
Expand Up @@ -865,15 +865,12 @@ function print_menu() {
echo '</ul>';
echo '</div>';
echo '<div class="bug-jump">';
echo '<form method="post" action="' . helper_mantis_url( 'jump_to_bug.php">' );
echo '<form method="post" action="' . helper_mantis_url( 'jump_to_bug.php" class="bug-jump-form">' );
# CSRF protection not required here - form does not result in modifications

if( ON == config_get( 'use_javascript' ) ) {
$t_bug_label = lang_get( 'issue_id' );
echo "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" value=\"$t_bug_label\" onfocus=\"if (this.value == '$t_bug_label') this.value = ''\" onblur=\"if (this.value == '') this.value = '$t_bug_label'\" />&nbsp;";
} else {
echo "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" />&nbsp;";
}
$t_bug_label = lang_get( 'issue_id' );
echo '<input type="hidden" name="bug_label" value="', $t_bug_label, '" />';
echo '<input type="text" name="bug_id" size="10" class="small" />&nbsp;';

echo '<input type="submit" class="button-small" value="' . lang_get( 'jump' ) . '" />&nbsp;';
echo '</form>';
Expand Down
3 changes: 2 additions & 1 deletion css/default.css
Expand Up @@ -111,7 +111,8 @@ td.login-info-right { width: 33%; padding: 0px; text-align: right; white-space:
#content { clear: both; margin: 0; padding: .5em; }
br { clear:both; }

.bug-jump { position: relative; top: -2.5em; right: .5em; float: right; }
.bug-jump { position: relative; top: -2.5em; right: .5em; float: right; z-index: 100; }
.field-default { color: #999; }

td.menu
{
Expand Down
26 changes: 26 additions & 0 deletions javascript/common.js
Expand Up @@ -147,8 +147,34 @@ $(document).ready( function() {
button: element.id + '_datetime_button'
});
});


$('.bug-jump').find('[name=bug_id]').focus( function() {
var bug_label = $('.bug-jump-form').find('[name=bug_label]').val();
if( $(this).val() == bug_label ) {
$(this).val('');
$(this).removeClass('field-default');
}
});
$('.bug-jump').find('[name=bug_id]').blur( function() {
var bug_label = $('.bug-jump-form').find('[name=bug_label]').val();
if( $(this).val() == '' ) {
$(this).val(bug_label);
$(this).addClass('field-default');
}
});
setBugLabel();
});

function setBugLabel() {
var bug_label = $('.bug-jump-form').find('[name=bug_label]').val();
var field = $('.bug-jump').find('[name=bug_id]');
if( field.val() == '' ) {
field.val(bug_label);
field.addClass('field-default');
}
}

/*
* String manipulation
*/
Expand Down
26 changes: 26 additions & 0 deletions javascript/dev/common.js
Expand Up @@ -151,8 +151,34 @@ $(document).ready( function() {
button: element.id + '_datetime_button'
});
});


$('.bug-jump').find('[name=bug_id]').focus( function() {
var bug_label = $('.bug-jump-form').find('[name=bug_label]').val();
if( $(this).val() == bug_label ) {
$(this).val('');
$(this).removeClass('field-default');
}
});
$('.bug-jump').find('[name=bug_id]').blur( function() {
var bug_label = $('.bug-jump-form').find('[name=bug_label]').val();
if( $(this).val() == '' ) {
$(this).val(bug_label);
$(this).addClass('field-default');
}
});
setBugLabel();
});

function setBugLabel() {
var bug_label = $('.bug-jump-form').find('[name=bug_label]').val();
var field = $('.bug-jump').find('[name=bug_id]');
if( field.val() == '' ) {
field.val(bug_label);
field.addClass('field-default');
}
}

/*
* String manipulation
*/
Expand Down

0 comments on commit e087425

Please sign in to comment.