Skip to content

Commit

Permalink
Misc tweaks based on code review comments
Browse files Browse the repository at this point in the history
- Update obsolete statements
- Reduce datepicker box width to avoid icon wrapping

Fixes #20040

Signed-off-by: Damien Regad <dregad@mantisbt.org>
- Whitespace adjustments
- Fixed typos in comments and documentation
  • Loading branch information
Rafik Robeal authored and dregad committed Dec 20, 2016
1 parent e3b8638 commit 253ad74
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions bug_actiongroup_page.php
Expand Up @@ -279,15 +279,15 @@
$t_bug_id = $f_bug_arr[0];
$t_bug = bug_get( $t_bug_id );
if( !date_is_null( $t_bug->due_date ) ) {
$t_date_to_display = date( config_get( 'datetime_field_format' ), $t_bug->due_date );
$t_date_to_display = date( config_get( 'normal_date_format' ), $t_bug->due_date );
}
}

echo '<input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="20" maxlength="16" ' .
echo '<input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" maxlength="16" ' .
'data-picker-locale="' . lang_get_current_datetime_locale() .
'" data-picker-format="' . config_get( 'datetime_picker_format' ) . '"' .
'" value="' . $t_date_to_display . '" />';
echo '<i class="fa fa-calendar fa-xlg"></i>';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
} else {
echo '<select name="' . $t_form . '" class="input-sm">';

Expand Down
4 changes: 2 additions & 2 deletions bug_change_status_page.php
Expand Up @@ -231,7 +231,7 @@
$t_date_to_display = '';

if( !date_is_null( $t_bug->due_date ) ) {
$t_date_to_display = date( config_get( 'datetime_field_format' ), $t_bug->due_date );
$t_date_to_display = date( config_get( 'normal_date_format' ), $t_bug->due_date );
}
?>
<!-- Due date -->
Expand All @@ -240,7 +240,7 @@
<?php echo lang_get( 'due_date' ) ?>
</th>
<td>
<input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="20" maxlength="16"
<input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" maxlength="16"
data-picker-locale="<?php lang_get_current_datetime_locale() ?>"
data-picker-format="<?php echo config_get( 'datetime_picker_format' ) ?>
<?php helper_get_tab_index() ?> value="<?php echo $t_date_to_display ?>" />
Expand Down
6 changes: 3 additions & 3 deletions bug_report_page.php
Expand Up @@ -347,7 +347,7 @@ class="dropzone-form"
$t_date_to_display = '';

if( !date_is_null( $f_due_date ) ) {
$t_date_to_display = date( config_get( 'datetime_field_format' ), $f_due_date );
$t_date_to_display = date( config_get( 'normal_date_format' ), $f_due_date );
}
?>
<tr>
Expand All @@ -358,8 +358,8 @@ class="dropzone-form"
<?php echo '<input ' . helper_get_tab_index() . ' type="text" id="due_date" name="due_date" class="datetimepicker input-sm" ' .
'data-picker-locale="' . lang_get_current_datetime_locale() .
'" data-picker-format="' . config_get( 'datetime_picker_format' ) . '" ' .
'size="20" maxlength="16" value="' . $t_date_to_display . '" />' ?>
<i class="fa fa-calendar fa-xlg"></i>
'size="20" maxlength="16" value="' . $t_date_to_display . '" />' ?>
<i class="fa fa-calendar fa-xlg datetimepicker"></i>
</td>
</tr>
<?php } ?>
Expand Down
6 changes: 3 additions & 3 deletions bug_update_page.php
Expand Up @@ -351,12 +351,12 @@
$t_date_to_display = '';

if( !date_is_null( $t_bug->due_date ) ) {
$t_date_to_display = date( config_get( 'datetime_field_format' ), $t_bug->due_date );
$t_date_to_display = date( config_get( 'normal_date_format' ), $t_bug->due_date );
}
echo '<input ' . helper_get_tab_index() . ' type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="20" ' .
echo '<input ' . helper_get_tab_index() . ' type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" ' .
'data-picker-locale="' . lang_get_current_datetime_locale() . '" data-picker-format="' . config_get( 'datetime_picker_format' ) . '" ' .
'" maxlength="16" value="' . $t_date_to_display . '" />';
echo '<i class="fa fa-calendar fa-xlg"></i>';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
} else {
if( !date_is_null( $t_bug->due_date ) ) {
echo date( config_get( 'short_date_format' ), $t_bug->due_date );
Expand Down
8 changes: 0 additions & 8 deletions config_defaults_inc.php
Expand Up @@ -1147,13 +1147,6 @@
*/
$g_datetime_picker_format = 'Y-MM-DD H:m';

/**
* datetime field format string
* go to http://www.php.net/manual/en/function.date.php
* for detailed instructions on date formatting
* @global string $g_datetime_field_format
*/
$g_datetime_field_format = 'Y-m-d H:i';

##############################
# MantisBT TimeZone Settings #
Expand Down Expand Up @@ -4276,7 +4269,6 @@
'bugnote_user_change_view_state_threshold',
'bugnote_user_delete_threshold',
'bugnote_user_edit_threshold',
'datetime_field_format',
'datetime_picker_format',
'cdn_enabled',
'change_view_status_threshold',
Expand Down
9 changes: 4 additions & 5 deletions core/lang_api.php
Expand Up @@ -355,12 +355,11 @@ function lang_get_defaulted( $p_string, $p_default = null, $p_lang = null ) {
}
}


/**
* Maps current lang string to moment.js locale https://github.com/moment/moment/tree/develop/locale
* @return string
* Maps current lang string to moment.js locale.
* @see https://github.com/moment/moment/tree/develop/locale
* @return string Two chars browser language code (e.g. 'de' for German)
*/

function lang_get_current_datetime_locale() {
$t_lang = lang_get_current();

Expand All @@ -370,4 +369,4 @@ function lang_get_current_datetime_locale() {
$t_key_arr = explode( ',', $t_entry );

return $t_key_arr[0];
}
}
1 change: 0 additions & 1 deletion core/layout_api.php
Expand Up @@ -313,7 +313,6 @@ function layout_head_javascript() {
* @return null
*/
function layout_body_javascript() {

if ( config_get_global( 'cdn_enabled' ) == ON ) {
# bootstrap
html_javascript_cdn_link( 'https://maxcdn.bootstrapcdn.com/bootstrap/' . BOOTSTRAP_VERSION . '/js/bootstrap.min.js', BOOTSTRAP_HASH );
Expand Down
4 changes: 2 additions & 2 deletions core/obsolete.php
Expand Up @@ -206,5 +206,5 @@
# changes in 2.0.0dev
config_obsolete( 'icon_path' );
config_obsolete( 'bug_print_page_fields' );
config_obsolete( 'calendar_js_date_format' );
config_obsolete( 'calendar_date_format' );
config_obsolete( 'calendar_js_date_format', 'datetime_picker_format' );
config_obsolete( 'calendar_date_format', 'normal_date_format' );
4 changes: 2 additions & 2 deletions css/ace-mantis.css
Expand Up @@ -281,13 +281,13 @@ textarea.input-xs, select.input-xs[multiple] {
display: block;
}

/* databicker */
/* date/time picker */
input.datetimepicker {
margin:0 5px 0 0;
}

i.datetimepicker {
cursor: pointer;
cursor: pointer;
}

.bootstrap-datetimepicker-widget.dropdown-menu {
Expand Down
11 changes: 10 additions & 1 deletion docbook/Admin_Guide/en-US/config/date.xml
Expand Up @@ -37,7 +37,16 @@
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>$g_datetime_picker_format</term>
<listitem>
<para>This format is used with the datetime picker widget.
See <ulink url="http://momentjs.com/docs/#/displaying/format/">datetime formatting guide</ulink>
for details.
Default is 'Y-MM-DD H:m'.
</para>
</listitem>
</varlistentry>
</variablelist>

</section>
9 changes: 5 additions & 4 deletions js/common.js
Expand Up @@ -210,9 +210,10 @@ $(document).ready( function() {
});

$('input[type=text].datetimepicker').each(function(index, element) {
$(this).datetimepicker({
locale: $(this).data('picker-locale'),
format: $(this).data('picker-format'),
$(this).datetimepicker({
locale: $(this).data('picker-locale'),
format: $(this).data('picker-format'),
useCurrent: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
Expand All @@ -224,7 +225,7 @@ $(document).ready( function() {
clear: 'fa fa-trash',
close: 'fa fa-times'
}
}).next().on(ace.click_event, function() {
}).next().on(ace.click_event, function() {
$(this).prev().focus();
});
});
Expand Down
4 changes: 2 additions & 2 deletions manage_proj_ver_edit_page.php
Expand Up @@ -100,8 +100,8 @@
<input type="text" id="proj-version-date-order" name="date_order" class="datetimepicker input-sm"
data-picker-locale="<?php echo lang_get_current_datetime_locale() ?>"
data-picker-format="<?php echo config_get( 'datetime_picker_format' ) ?>"
size="32" value="<?php echo (date_is_null( $t_version->date_order ) ? '' : string_attribute( date( config_get( 'datetime_field_format' ), $t_version->date_order ) ) ) ?>" />
<i class="fa fa-calendar fa-xlg"></i>
size="16" value="<?php echo (date_is_null( $t_version->date_order ) ? '' : string_attribute( date( config_get( 'normal_date_format' ), $t_version->date_order ) ) ) ?>" />
<i class="fa fa-calendar fa-xlg datetimepicker"></i>
</td>
</tr>
<tr>
Expand Down

0 comments on commit 253ad74

Please sign in to comment.