-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters