Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/63859
Change subject: (bug 48145) Adding calendar hint message
......................................................................
(bug 48145) Adding calendar hint message
Message informing about the calendar that is detected automatically when
specifying a date.
The message will be shown only when the specified date lies within a time frame
when multiple
calendars had been in use. Since only Gregorian and Julian calendar are
implemented at the
moment, this is specifically implemented according to those calendars.
In addition to the plain message, a links allows switching between the
currently implemented
calendars.
Change-Id: I8b3d2bb6c04b01fc987c2c4ed9c0bd406a824134
---
M ValueView/ValueView.i18n.php
M ValueView/ValueView.resources.php
M ValueView/resources/jquery.valueview/valueview.experts/experts.TimeInput.js
3 files changed, 69 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues
refs/changes/59/63859/1
diff --git a/ValueView/ValueView.i18n.php b/ValueView/ValueView.i18n.php
index d6e82e5..531b0cc 100644
--- a/ValueView/ValueView.i18n.php
+++ b/ValueView/ValueView.i18n.php
@@ -48,6 +48,8 @@
// TimeInput expert:
'valueview-expert-timeinput-precision' => 'Precision:',
'valueview-expert-timeinput-calendar' => 'Calendar:',
+ 'valueview-expert-timeinput-calendarhint' => '(proleptic $1 calendar)',
+ 'valueview-expert-timeinput-calendarhint-switch' => '→ change to
$1',
'valueview-preview-label' => 'will be displayed as:',
'valueview-preview-novalue' => 'no valid value recognized',
@@ -68,6 +70,8 @@
{{Identical|Empty}}',
'valueview-expert-timeinput-precision' => 'Label for the user interface
element used to set a specific precision (e.g. hour, day, month, year) when
entering a time value.',
'valueview-expert-timeinput-calendar' => 'Label for the user interface
element used to select a specific calendar (e.g. Gregorian, Julian) entering a
time value.',
+ 'valueview-expert-timeinput-calendarhint' => 'Message informing about
the calendar (e.g. Gregorian) that is detected automatically when specifying a
date. The message is shown only when the specified date lies within a time
frame when multiple calendars had been in use. $1 is the name of the calendar
that is detected by the system.',
+ 'valueview-expert-timeinput-calendarhint-switch' => 'Label of the link
manually switching the calendar (e.g. from Gregorian to Julian) directly at the
preview (in combination with the calendar hint message). $1 is the name of the
other calender that may be switched to. (Currently, only Gregorian and Julian
calendars are implemented.)',
'valueview-preview-label' => 'Label displayed above the preview of a
value that is being entered by the user. The preview is the system\'s
interpretation of the specified value and - since there is no strict definition
for a user how to specify values - visualizes how the value will be displayed
later on after the value has been saved.',
'valueview-preview-novalue' => 'Message displayed instead of an input
value\'s preview when no value is specified yet or when the specified value
could not be interpreted by the system.',
'valueview-listrotator-auto' => 'Label of the link to have the system
automatically select the most appropriate value from a "listrotator" widget.
The "listrotator" basically is a facade for a drop-down select box allowing to
pick a value from a list of values. In addition to the defined values, an
"automatic" option may be selected that makes the system pick the most
appropriate value according to an associated input element.',
diff --git a/ValueView/ValueView.resources.php
b/ValueView/ValueView.resources.php
index d34221e..647fdb8 100644
--- a/ValueView/ValueView.resources.php
+++ b/ValueView/ValueView.resources.php
@@ -210,6 +210,8 @@
'valueview-expert-advancedoptions',
'valueview-expert-timeinput-precision',
'valueview-expert-timeinput-calendar',
+ 'valueview-expert-timeinput-calendarhint',
+
'valueview-expert-timeinput-calendarhint-switch',
'valueview-preview-label',
'valueview-preview-novalue',
),
diff --git
a/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeInput.js
b/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeInput.js
index 0c26c9b..e6f95a3 100644
---
a/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeInput.js
+++
b/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeInput.js
@@ -75,6 +75,12 @@
$calendar: null,
/**
+ * Node of the hint giving information about the automatically
selected calendar.
+ * @type {jQuery}
+ */
+ $calendarhint: null,
+
+ /**
* @see jQuery.valueview.Expert._init
*/
_init: function() {
@@ -113,6 +119,7 @@
$( this ).data( 'listrotator' ).rotate(
value.precision() );
self._setRawValue( value );
self._updatePreview( value );
+ self._updateCalendarHint( value );
self._viewNotifier.notify( 'change' );
} )
.on( 'listrotatorselected.' + this.uiBaseClass,
function( event, precision ) {
@@ -121,6 +128,7 @@
: new Time( self.$input.val(), {
precision: $( this ).data( 'listrotator' ).value() } );
self._setRawValue( value );
self._updatePreview( value );
+ self._updateCalendarHint( value );
self._viewNotifier.notify( 'change' );
} )
.appendTo( this.$precisionContainer );
@@ -143,6 +151,7 @@
$( this ).data( 'listrotator' ).rotate(
value.calendarText() );
self._setRawValue( value );
self._updatePreview( value );
+ self._updateCalendarHint( value );
self._viewNotifier.notify( 'change' );
} )
.on( 'listrotatorselected', function( event ) {
@@ -153,6 +162,7 @@
$( this ).data( 'listrotator' ).rotate(
value.calendarText() );
self._setRawValue( value );
self._updatePreview( value );
+ self._updateCalendarHint( value );
self._viewNotifier.notify( 'change' );
} )
.appendTo( this.$calendarContainer );
@@ -160,6 +170,15 @@
var $toggler = $( '<a/>' )
.addClass( this.uiBaseClass + '-advancedtoggler' )
.text( mw.msg( 'valueview-expert-advancedoptions' ) );
+
+ this.$calendarhint = $( '<div/>' )
+ .addClass( this.uiBaseClass + '-calendarhint' )
+ .append( $( '<span/>' ).addClass( this.uiBaseClass +
'-calendarhint-message' ) )
+ .append(
+ $( '<a/>' )
+ .addClass( this.uiBaseClass +
'-calendarhint-switch' )
+ .attr( 'href', 'javascript:void(0);' )
+ );
this.$input = $( '<input/>', {
type: 'text',
@@ -170,13 +189,14 @@
var value = self.$input.data( 'timeinput'
).value();
if( oldValue === '' && value === null ||
self.$input.val() === '' ) {
self._updatePreview( null );
+ self._updateCalendarHint();
}
} )
.timeinput()
// TODO: Move input extender out of here to a more
generic place since it is not
// TimeInput specific.
.inputextender( {
- content: [ $toggler, this.$precisionContainer,
this.$calendarContainer, this.$preview ],
+ content: [ $toggler, this.$precisionContainer,
this.$calendarContainer, this.$preview, this.$calendarhint ],
initCallback: function() {
self.$precision.data( 'listrotator'
).initWidths();
self.$calendar.data( 'listrotator'
).initWidths();
@@ -188,6 +208,7 @@
} )
.on( 'timeinputupdate.' + this.uiBaseClass, function(
event, value ) {
self._updatePreview( value );
+ self._updateCalendarHint( value );
if( value && value.isValid() ) {
self.$precision.data( 'listrotator'
).rotate( value.precision() );
self.$calendar.data( 'listrotator'
).rotate( value.calendarText() );
@@ -208,6 +229,8 @@
this.$calendar.data( 'listrotator' ).destroy();
this.$calendar.remove();
this.$calendarContainer.remove();
+
+ this.$calendarhint.remove();
this.$previewValue.remove();
this.$preview.remove();
@@ -240,6 +263,44 @@
this.$previewValue
.removeClass( 'valueview-preview-novalue' )
.text( value.text() )
+ }
+ },
+
+ /**
+ * Updates the calendar hint message.
+ *
+ * @param {time.Time} [value] Message will get hidden when
omitted.
+ */
+ _updateCalendarHint: function( value ) {
+ if( value && value.year() > 1581 && value.year() < 1930
&& value.precision() > 10 ) {
+ var self = this;
+
+ var otherCalendar = ( value.calendarText() ===
timeSettings.calendarnames[0][0] )
+ ? timeSettings.calendarnames[1][0]
+ : timeSettings.calendarnames[0][0];
+
+ this.$calendarhint.children( '.' +
this.uiBaseClass + '-calendarhint-message' )
+ .text( mw.msg(
'valueview-expert-timeinput-calendarhint', value.calendarText() ) );
+
+ this.$calendarhint.children( '.' +
this.uiBaseClass + '-calendarhint-switch' )
+ .off( 'click.' + this.uiBaseClass )
+ .on( 'click.' + this.uiBaseClass, function(
event ) {
+ self.$calendar.data( 'listrotator'
).rotate( otherCalendar );
+
+ var value = ( self.$precision.data(
'listrotator' ).value() )
+ ? new Time( self.$input.val(),
{ precision: self.$precision.data( 'listrotator' ).value(), calendarname:
self.$calendar.data( 'listrotator' ).value() } )
+ : new Time( self.$input.val(),
{ calendarname: self.$calendar.data( 'listrotator' ).value() } );
+
+ self._setRawValue( value );
+ self._updatePreview( value );
+ self._updateCalendarHint( value );
+ self._viewNotifier.notify( 'change' );
+ } )
+ .html( mw.msg(
'valueview-expert-timeinput-calendarhint-switch', otherCalendar ) );
+
+ this.$calendarhint.show();
+ } else {
+ this.$calendarhint.hide();
}
},
@@ -307,6 +368,7 @@
if( this._newValue !== false ) {
this.$input.data( 'timeinput' ).value(
this._newValue );
this._updatePreview( this._newValue );
+ this._updateCalendarHint( this._newValue );
if( this._newValue !== null ) {
this.$precision.data( 'listrotator'
).rotate( this._newValue.precision() );
this.$calendar.data( 'listrotator'
).rotate( this._newValue.calendarText() );
--
To view, visit https://gerrit.wikimedia.org/r/63859
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b3d2bb6c04b01fc987c2c4ed9c0bd406a824134
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits