Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ Other methods an `Expert` needs to provide:

## Release notes

### 0.14.4 (2015-06-08)
### 0.14.4 (2015-06-10)
* Added expert for `UnDeserializableValue`s.
* Updated DataValues JavaScript dependency to version 0.7.

### 0.14.3 (2015-04-02)
* Fix premature afterparse handling (e.g. save) of parsed values.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require": {
"php": ">=5.3.0",
"data-values/javascript": "~0.6.0"
"data-values/javascript": "~0.7.0"
},
"autoload": {
"files": [
Expand Down
24 changes: 13 additions & 11 deletions src/ExpertExtender/ExpertExtender.CalendarHint.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
( function( $, ExpertExtender, Time ) {
( function( $, ExpertExtender, TimeValue ) {
'use strict';

/**
Expand Down Expand Up @@ -94,28 +94,30 @@
return;
}

// Are we in the interesting range
if( !( value.year() > 1581 && value.year() < 1930 && value.precision() > 10 ) ) {
var assumeCalendar = value.getYear() <= 1581 || value.getYear() >= 1930;

if( assumeCalendar || value.getOption( 'precision' ) <= 10 ) {
this.$calendarhint.hide();
return;
}

var msg = this._messageProvider.getMessage(
this._prefix + '-' + value.calendar().toLowerCase()
);
var calendarModel = value.getOption( 'calendarModel' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does a calendarModelcalendarName option come from? I think it doesn't exist and needs to be replaced with a TimeValue.getCalendarModelKeyByUri call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you did not test the pull request after your additional changes in DataValuesJavaScript? What do you expect value.getOption( 'calendarModel' ) to return being aware that value is a TimeValue object (https://github.com/wmde/DataValuesJavascript/blob/master/src/values/TimeValue.js)? If it is nor the URI, something is wrong as the call to TimeValue.getCalendarModelKeyByUri is just two lines below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the comment on the wrong line, see the calendarName option below.

msg = this._messageProvider.getMessage(
this._prefix + '-' + TimeValue.getCalendarModelKeyByUri( calendarModel )
);

if( !msg ) {
return;
}

this.$calendarhint.children( '.' + this._prefix + '-message' ).text( msg );

this._otherCalendar = ( value.calendar() === Time.CALENDAR.GREGORIAN )
? Time.CALENDAR.JULIAN
: Time.CALENDAR.GREGORIAN;
this._otherCalendar = calendarModel === TimeValue.CALENDARS.GREGORIAN
? TimeValue.CALENDARS.JULIAN
: TimeValue.CALENDARS.GREGORIAN;

msg = this._messageProvider.getMessage(
this._prefix + '-switch-' + this._otherCalendar.toLowerCase()
this._prefix + '-switch-' + TimeValue.getCalendarModelKeyByUri( this._otherCalendar )
);
if( msg ) {
this.$calendarhint.children( '.' + this._prefix + '-switch' ).html( msg );
Expand All @@ -138,4 +140,4 @@
this._otherCalendar = null;
}
} );
}( jQuery, jQuery.valueview.ExpertExtender, time.Time ) );
}( jQuery, jQuery.valueview.ExpertExtender, dataValues.TimeValue ) );
2 changes: 1 addition & 1 deletion src/ExpertExtender/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
'ExpertExtender.CalendarHint.css',
),
'dependencies' => array(
'dataValues.TimeValue',
'jquery.valueview.ExpertExtender',
'time.js'
),
'messages' => array(
'valueview-expertextender-calendarhint-gregorian',
Expand Down
47 changes: 17 additions & 30 deletions src/experts/TimeInput.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
( function( $, vv, time ) {
( function( $, vv, TimeValue ) {
'use strict';

var Time = time.Time,
timeSettings = time.settings;

var PARENT = vv.experts.StringValue;

/**
Expand Down Expand Up @@ -38,7 +35,7 @@
$.proxy( this._onRotatorChange, this ),
function() {
var value = self.viewState().value();
return value && value.getValue().precision();
return value && value.getOption( 'precision' );
}
);

Expand All @@ -53,7 +50,7 @@
$.proxy( this._onRotatorChange, this ),
function() {
var value = self.viewState().value();
return value && value.getValue().calendar();
return value && value.getOption( 'calendarModel' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to this line. I fixed it in my commit, see 929a808#diff-49060d53e8ad9e0d74b8e4ea672589a5L53.

}
);

Expand All @@ -64,8 +61,7 @@
new vv.ExpertExtender.CalendarHint(
this._messageProvider,
function() {
var value = self.viewState().value();
return value && value.getValue();
return self.viewState().value();
},
function( value ) {
// FIXME: Do not use private function:
Expand Down Expand Up @@ -143,13 +139,13 @@
valueCharacteristics: function() {
var options = {},
precision = this.precisionRotator && this.precisionRotator.getValue() || null,
calendarname = this.calendarRotator && this.calendarRotator.getValue() || null;
calendarUri = this.calendarRotator && this.calendarRotator.getValue() || null;

if( precision !== null ) {
options.precision = precision;
}
if( calendarname !== null ) {
options.calendar = calendarNameToUri( calendarname );
if( calendarUri !== null ) {
options.calendar = calendarUri;
}

return options;
Expand All @@ -162,11 +158,12 @@
* @return {Object[]} [{ value: <{number}>, label: <{string}>}, ...]
*/
function getPrecisionValues() {
var precisionValues = [];
$.each( timeSettings.precisiontexts, function( i, text ) {
if( i <= Time.PRECISION.DAY ) {
var precisionValues = [],
dayPrecision = TimeValue.getPrecisionById( 'DAY' );
$.each( TimeValue.PRECISIONS, function( precisionValue, precision ) {
if( precisionValue <= dayPrecision ) {
// TODO: Remove this check as soon as time values are supported.
precisionValues.unshift( { value: i, label: text } );
precisionValues.unshift( { value: precisionValue, label: precision.text } );
}
} );
return precisionValues;
Expand All @@ -180,23 +177,13 @@
*/
function getCalendarValues( messageProvider ) {
var calendarValues = [];
$.each( timeSettings.calendarnames, function( calendarKey, calendarTerms ) {
$.each( TimeValue.CALENDARS, function( key, uri ) {
var label = messageProvider.getMessage(
'valueview-expert-timevalue-calendar-' + calendarTerms[0].toLowerCase()
) || calendarTerms[0];
calendarValues.push( { value: calendarTerms[0], label: label } );
'valueview-expert-timevalue-calendar-' + key.toLowerCase()
) || key.toLowerCase();
calendarValues.push( { value: uri, label: label } );
} );
return calendarValues;
}

/**
* @ignore
*
* @param {string} calendarname
* @return {string}
*/
function calendarNameToUri( calendarname ) {
return new Time( { calendarname: calendarname, precision: 0, year: 0 } ).calendarURI();
}

}( jQuery, jQuery.valueview, time ) );
}( jQuery, jQuery.valueview, dataValues.TimeValue ) );
2 changes: 1 addition & 1 deletion src/experts/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
'TimeInput.css',
),
'dependencies' => array(
'dataValues.TimeValue',
'jquery.valueview.ExpertExtender',
'jquery.valueview.ExpertExtender.CalendarHint',
'jquery.valueview.ExpertExtender.Container',
Expand All @@ -127,7 +128,6 @@
'jquery.valueview.ExpertExtender.Toggler',
'jquery.valueview.experts',
'jquery.valueview.Expert',
'time.js',
'util.MessageProvider',
),
'messages' => array(
Expand Down
23 changes: 10 additions & 13 deletions tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$,
ExpertExtender,
testExpertExtenderExtension,
Time,
TimeValue,
HashMessageProvider,
sinon,
QUnit,
Expand Down Expand Up @@ -37,11 +37,11 @@
'valueview-expertextender-calendarhint-switch-julian': 'MSG2'
} ),
function() {
return new time.Time( '2014-01-01' );
return new TimeValue( '2014-01-01T00:00:00Z' );
},
null
);
var $extender = $( '<div />' ).appendTo( 'body' ) ;
var $extender = $( '<div />' ).appendTo( 'body' );

calendarHint.init( $extender );
calendarHint.draw();
Expand All @@ -58,7 +58,7 @@
'valueview-expertextender-calendarhint-switch-julian': 'MSG2'
} ),
function() {
return new Time( '1901-01-01' );
return new TimeValue( '1901-01-01T00:00:00Z' );
},
null
);
Expand All @@ -74,7 +74,7 @@

QUnit.test( 'switch switches the calendar model', function( assert ) {
var setSpy = sinon.spy();
var timeValue = new Time( '1901-01-01' );
var timeValue = new TimeValue( '1901-01-01T00:00:00Z' );
var calendarHint = new ExpertExtender.CalendarHint(
new HashMessageProvider( {
'valueview-expertextender-calendarhint-gregorian': 'MSG1',
Expand Down Expand Up @@ -102,7 +102,7 @@

QUnit.test( 'switch twice switches the calendar model back', function( assert ) {
var setSpy = sinon.spy();
var timeValue = new Time( '1901-01-01' );
var timeValue = new TimeValue( '1901-01-01T00:00:00Z' );
var calendarHint = new ExpertExtender.CalendarHint(
new HashMessageProvider( {
'valueview-expertextender-calendarhint-gregorian': 'MSG1',
Expand All @@ -125,12 +125,9 @@
sinon.assert.calledOnce( setSpy );
assert.equal( setSpy.firstCall.args[0], 'Julian' );

timeValue = new Time( {
year: timeValue.year(),
month: timeValue.month(),
day: timeValue.day(),
calendarname: Time.CALENDAR.JULIAN,
precision: timeValue.precision()
timeValue = new TimeValue( timeValue.toJSON().time, {
calendarModel: TimeValue.CALENDARS.JULIAN,
precision: timeValue.getOption( 'precision' )
} );
calendarHint.draw();

Expand All @@ -146,7 +143,7 @@
jQuery,
jQuery.valueview.ExpertExtender,
jQuery.valueview.tests.testExpertExtenderExtension,
time.Time,
dataValues.TimeValue,
util.HashMessageProvider,
sinon,
QUnit,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/ExpertExtender/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
'ExpertExtender.CalendarHint.tests.js',
),
'dependencies' => array(
'dataValues.TimeValue',
'jquery.valueview.ExpertExtender.CalendarHint',
'jquery.valueview.test.testExpertExtenderExtension',
'util.HashMessageProvider',
'time.js'
),
),

Expand Down
2 changes: 1 addition & 1 deletion tests/src/experts/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
'TimeInput.tests.js',
),
'dependencies' => array(
'dataValues.TimeValue',
'jquery.valueview.experts.TimeInput',
'jquery.valueview.tests.testExpert',
'time.js',
),
),

Expand Down