Skip to content

Commit

Permalink
Merge "Add TabularData datatype"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Apr 18, 2017
2 parents 24c6c2a + 50bc6f7 commit 5c8861e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/experts/TabularData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
( function( $, vv ) {
'use strict';

var PARENT = vv.experts.StringValue;

/**
* `Valueview` expert for adding specialized handling for `tabular-data` data type.
* Without this more specialized expert, the `StringValue` expert would be used since the
* `tabular-data` data type is using the `String` data value type.
* This expert is based on the `StringValue` expert but will add a drop-down for choosing
* Commons data sources. It will also display the value as a link to Commons.
* @class jQuery.valueview.experts.TabularData
* @extends jQuery.valueview.experts.StringValue
* @since 0.1
* @licence GNU GPL v2+
* @author Amir Sarabadani <[email protected]>
*/
vv.experts.TabularData = vv.expert( 'TabularData', PARENT, {
/**
* @inheritdoc
* @protected
*/
_init: function() {
PARENT.prototype._init.call( this );

var notifier = this._viewNotifier,
$input = this.$input;

$input.commonssuggester( {
apiUrl: this._options.commonsApiUrl,
namespace: 'Data',
contentModel: 'Tabular.JsonConfig'
} );

// Using the inputautoexpand plugin, the position of the dropdown needs to be updated
// whenever the input box expands vertically:
$input
.on( 'eachchange', function( event, oldValue ) {
// TODO/OPTIMIZE: Only reposition when necessary, i.e. when expanding vertically
$input.data( 'commonssuggester' ).repositionMenu();
} )
.on( 'commonssuggesterchange', function( event, response ) {
notifier.notify( 'change' );
$input.data( 'inputautoexpand' ).expand();
} );
}
} );

}( jQuery, jQuery.valueview ) );
13 changes: 13 additions & 0 deletions src/experts/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
),
),

'jquery.valueview.experts.TabularData' => $moduleTemplate + array(
'scripts' => array(
'TabularData.js',
),
'dependencies' => array(
'jquery.event.special.eachchange',
'jquery.ui.commonssuggester',
'jquery.valueview.experts',
'jquery.valueview.experts.StringValue',
'jquery.valueview.Expert',
),
),

'jquery.valueview.experts.EmptyValue' => $moduleTemplate + array(
'scripts' => array(
'EmptyValue.js',
Expand Down

0 comments on commit 5c8861e

Please sign in to comment.