Henning Snater has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64091


Change subject: (bug 48145) Displaying calendar model
......................................................................

(bug 48145) Displaying calendar model

Displaying the calendar the time value is using if the date lies within a
time frame when multiple calendars have been in use or if the time value
features a calendar that is uncommon for the specified time.

Change-Id: Ie02273f24dc2562a7de354904b0bef20ea35ba63
---
M ValueView/ValueView.resources.php
A ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.css
M ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.js
3 files changed, 48 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues 
refs/changes/91/64091/1

diff --git a/ValueView/ValueView.resources.php 
b/ValueView/ValueView.resources.php
index c11533e..58fc807 100644
--- a/ValueView/ValueView.resources.php
+++ b/ValueView/ValueView.resources.php
@@ -207,6 +207,9 @@
                        'scripts' => array(
                                
'jquery.valueview/valueview.experts/experts.TimeValue.js',
                        ),
+                       'styles' => array(
+                               
'jquery.valueview/valueview.experts/experts.TimeValue.css',
+                       ),
                        'dependencies' => array(
                                'jquery.valueview.experts.staticdom',
                                'jquery.valueview.BifidExpert',
diff --git 
a/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.css 
b/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.css
new file mode 100644
index 0000000..ddebf72
--- /dev/null
+++ 
b/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.css
@@ -0,0 +1,16 @@
+/**
+ * Styles for valueview's TimeValue expert.
+ *
+ * @since 0.1
+ * @file
+ * @ingroup ValueView
+ *
+ * @license GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+
+.valueview-expert-timevalue sup {
+       font-style: italic;
+       margin-left: 0.5em;
+       line-height: 1;
+}
diff --git 
a/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.js 
b/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.js
index c32e6e6..58cf9f4 100644
--- 
a/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.js
+++ 
b/ValueView/resources/jquery.valueview/valueview.experts/experts.TimeValue.js
@@ -3,6 +3,7 @@
  * @ingroup ValueView
  * @licence GNU GPL v2+
  * @author Daniel Werner < [email protected] >
+ * @author H. Snater < [email protected] >
  */
 ( function( dv, vp, $, vv ) {
        'use strict';
@@ -43,9 +44,34 @@
                         * @param {jQuery.valueview.ViewState} viewState
                         */
                        domBuilder: function( currentRawValue, viewState ) {
-                               return $( '<span/>', {
-                                       text: currentRawValue === null ? '' : 
currentRawValue.text()
-                               } );
+                               var $node = $( '<span/>' );
+
+                               if( !currentRawValue ) {
+                                       return $node;
+                               }
+
+                               // Display the calendar being used if the date 
lies within a time frame when
+                               // multiple calendars have been in use or if 
the time value features a calendar that
+                               // is uncommon for the specified time:
+                               // TODO: This needs to be shaped more generic 
instead of focusing on Gregorian/Julian calendar.
+                               var year = currentRawValue.year();
+
+                               if(
+                                       currentRawValue.precision() > 10
+                                       && (
+                                               year > 1581 && year < 1930
+                                               || year <= 1581 && 
currentRawValue.calendarText() === 'Gregorian'
+                                               || year >= 1930 && 
currentRawValue.calendarText() === 'Julian'
+                                       )
+                               ) {
+                                       $node
+                                       .append( $( '<span/>' ).text( 
currentRawValue.text() ) )
+                                       .append( $( '<sup/>' ).text( 
currentRawValue.calendarText() ) );
+                               } else {
+                                       $node.text( currentRawValue.text() );
+                               }
+
+                               return $node;
                        },
                        baseExpert: editableExpert
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/64091
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie02273f24dc2562a7de354904b0bef20ea35ba63
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

Reply via email to