[MediaWiki-commits] [Gerrit] entityselector: Select only if item changed - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/193075 Change subject: entityselector: Select only if item changed .. entityselector: Select only if item changed -> 90853 Change-Id: I41f6ad789ad463bed24a23f762a37a95e93408cb --- M lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js 1 file changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/75/193075/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js index 2d444d6..20a3c0e 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js @@ -355,7 +355,11 @@ self._close(); self._trigger( 'change' ); - self._select( item.getEntityStub() ); + var entityStub = item.getEntityStub(); + + if( !self._selectedEntity || entityStub.id !== self._selectedEntity.id ) { + self._select( entityStub ); + } } } ); -- To view, visit https://gerrit.wikimedia.org/r/193075 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I41f6ad789ad463bed24a23f762a37a95e93408cb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (hotfix) $.util.getDirectionality: Namespace might not be de... - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/191050 Change subject: (hotfix) $.util.getDirectionality: Namespace might not be defined .. (hotfix) $.util.getDirectionality: Namespace might not be defined Change-Id: Id0563da5bf8ccd5b4e126824c348ba50c5a8c026 --- M repo/resources/jquery/jquery.util.getDirectionality.js 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/50/191050/1 diff --git a/repo/resources/jquery/jquery.util.getDirectionality.js b/repo/resources/jquery/jquery.util.getDirectionality.js index 44279a1..b5ecbb9 100644 --- a/repo/resources/jquery/jquery.util.getDirectionality.js +++ b/repo/resources/jquery/jquery.util.getDirectionality.js @@ -1,6 +1,8 @@ ( function ( $ ) { 'use strict'; +$.util = $.util || {}; + /** * Returns the directionality of a language by querying the Universal Language Selector. If ULS is * not available the HTML element's `dir` attribute is evaluated. If that is unset, `auto` is -- To view, visit https://gerrit.wikimedia.org/r/191050 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id0563da5bf8ccd5b4e126824c348ba50c5a8c026 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Edit References along with Statement - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190799 Change subject: Edit References along with Statement .. Edit References along with Statement The change switches to editing References along with Statements while the functionality to edit References individually is preserved. While the change strives to integrated the functionality only, no optical adjustments are applied. Requires adjusting the Selenium tests. - 87759 Change-Id: I9444ae579c297cc81689c4d95a38793a757f0c34 --- M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementgroupview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js A lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/resources.php M repo/resources/Resources.php M repo/resources/wikibase.ui.entityViewInit.js 14 files changed, 396 insertions(+), 111 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/99/190799/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index b398e48..de29190 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -27,6 +27,10 @@ * @param {dataTypes.DataTypeStore} options.dataTypeStore *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` *object when interacting on a "value" `Variation`. + * @param {wikibase.entityChangers.ReferencesChanger} [options.referencesChanger] + *Required if `Statement` `Reference`s should not be saved along with each `Statement` but + *are supposed to be saved individually (e.g. by applying individual edit toolbars to the + *`referenceview`s). */ $.widget( 'wikibase.itemview', PARENT, { /** @@ -36,7 +40,8 @@ options: { entityStore: null, valueViewBuilder: null, - dataTypeStore: null + dataTypeStore: null, + referencesChanger: null }, /** @@ -88,7 +93,8 @@ entityType: this.options.value.getType(), entityStore: this.options.entityStore, valueViewBuilder: this.options.valueViewBuilder, - entityChangersFactory: this.options.entityChangersFactory + entityChangersFactory: this.options.entityChangersFactory, + referencesChanger: this.options.referencesChanger } ) .statementgrouplabelscroll(); diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js index 2df4fdf..eafd67d 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js @@ -26,6 +26,10 @@ * @param {dataTypes.DataTypeStore} options.dataTypeStore *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` *object when interacting on a "value" `Variation`. + * @param {wikibase.entityChangers.ReferencesChanger} [options.referencesChanger] + *Required if `Statement` `Reference`s should not be saved along with each `Statement` but + *are supposed to be saved individually (e.g. by applying individual edit toolbars to the + *`referenceview`s). */ $.widget( 'wikibase.propertyview', PARENT, { /** @@ -35,7 +39,8 @@ options: { entityStore: null, valueViewBuilder: null, - dataTypeStore: null + dataTypeStore: null, + referencesChanger: null }, /** @@ -108,7 +113,8 @@ entityType: this.options.value.getType(), entityStore: this.options.entityStore, valueViewBuilder: this.options.valueViewBuilder, - entityChangersFactory: this.options.entityChangersFactory + entityChangersFactory: this.options.entityChangersFactory, +
[MediaWiki-commits] [Gerrit] Updated entityview - itemview/propertyview relationship - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190782 Change subject: Updated entityview - itemview/propertyview relationship .. Updated entityview - itemview/propertyview relationship Change-Id: I592bab460c2f0474caee43a0d8bb933d9ad65bfc --- M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js 3 files changed, 49 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/82/190782/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index 33ff2e7..ee9d2c1 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -4,7 +4,7 @@ var PARENT = $.ui.TemplatedWidget; /** - * Abstract base view for displaying Wikibase `Entity`s. + * Abstract base view for displaying a Wikibase `Entity`. * @class jQuery.wikibase.entityview * @extends jQuery.ui.TemplatedWidget * @abstract @@ -22,17 +22,6 @@ *single language code. * @param {wikibase.entityChangers.EntityChangersFactory} options.entityChangersFactory *Required to be able to store changes applied to the entity. - * @param {wikibase.store.EntityStore} options.entityStore - *Required by sub-components of the `entityview` to enable those to dynamically query for - *`Entity` objects. - * @param {wikibase.ValueViewBuilder} options.valueViewBuilder - *Required by the `snakview` interfacing a `snakview` "value" `Variation` to - *`jQuery.valueview`. - * @param {dataTypes.DataTypeStore} options.dataTypeStore - *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` - *object when interacting on a "value" `Variation`. - * - * @throws {Error} when called. */ /** * @event afterstartediting @@ -49,7 +38,6 @@ $.widget( 'wikibase.entityview', PARENT, { /** * @inheritdoc -* @property {Object} * @protected */ options: { @@ -68,32 +56,30 @@ }, value: null, languages: null, - entityStore: null, - valueViewBuilder: null, - dataTypeStore: null + entityChangersFactory: null }, /** * @property {jQuery} -* @protected +* @readonly */ $label: null, /** * @property {jQuery} -* @protected +* @readonly */ $description: null, /** * @property {jQuery} -* @protected +* @readonly */ $aliases: null, /** * @property {jQuery|null} -* @protected +* @readonly */ $entityTerms: null, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index 23a27b5..b398e48 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -17,12 +17,32 @@ * @author H. Snater < mediaw...@snater.com > * * @constructor + * + * @param {wikibase.store.EntityStore} options.entityStore + *Required by sub-components of the `entityview` to enable those to dynamically query for + *`Entity` objects. + * @param {wikibase.ValueViewBuilder} options.valueViewBuilder + *Required by the `snakview` interfacing a `snakview` "value" `Variation` to + *`jQuery.valueview`. + * @param {dataTypes.DataTypeStore} options.dataTypeStore + *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` + *object when interacting on a "value" `Variation`. */ $.widget( 'wikibase.itemview', PARENT, { /** -* @property {jQuery} +* @inheritdoc * @protected */ + options: { + entityStore: null, + valueViewBuilder: null, + dataTypeStore: null + }, + + /** +* @property {jQuery} +* @readonly +*/ $statements: null, /** diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js index 95f0595..2df4fdf 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js @@ -16,17 +16,37 @@ * @author H. Snater < mediaw...@snater.com > * * @constructor + * + * @param {wikibase.store.EntityStore} options.entityStore + *Required by sub-components of the `entityview` to enable
[MediaWiki-commits] [Gerrit] referenceview: Removed internal caching of initial values - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190456 Change subject: referenceview: Removed internal caching of initial values .. referenceview: Removed internal caching of initial values Change-Id: Ifb546b27f1d29baad5b1cbe92db24428c5a05cd2 --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js 1 file changed, 41 insertions(+), 78 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/56/190456/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index ccdbdb8..fc628c3 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -86,24 +86,6 @@ }, /** -* `Reference` object represented by this widget. -* @property {wikibase.datamodel.Reference} -* @private -*/ - _reference: null, - - /** -* Caches the `SnakList` of the `Reference` `Snak`s the `referenceview` has been initialized -* with. The `Snak`s are split into groups featuring the same `Property`. Removing one of those -* groups results in losing the reference to those `Snak`s. Therefore, `_initialSnakList` is -* used to rebuild the list of `Snak`s when cancelling and is used to query whether the `Snak`s -* represent the initial state. -* @property {wikibase.datamodel.SnakList} -* @private -*/ - _initialSnakList: null, - - /** * Whether the widget is currently in edit mode. * @property {boolean} [_isInEditMode=false] * @private @@ -128,19 +110,6 @@ var self = this; - if ( this.option( 'value' ) ) { - this._reference = this.option( 'value' ); - // Overwrite the value since listItemAdapter is the snaklistview prototype which - // requires a wb.datamodel.SnakList object for initialization: - // FIXME: Do not overwrite the value - this._initialSnakList = this._reference.getSnaks(); - this.options.value = this._initialSnakList.getGroupedSnakLists(); - } - - if( !this._initialSnakList ) { - this._initialSnakList = new wb.datamodel.SnakList(); - } - this.$listview.listview( { listItemAdapter: new $.wikibase.listview.ListItemAdapter( { listItemWidget: $.wikibase.snaklistview, @@ -154,7 +123,7 @@ }; } } ), - value: this.option( 'value' ) + value: this.options.value ? this.options.value.getSnaks().getGroupedSnakLists() : [] } ); this._updateReferenceHashClass( this.value() ); @@ -239,19 +208,12 @@ * Sets the `Reference` to be represented by the view or returns the `Reference` currently * represented by the widget. * -* @param {wikibase.datamodel.Reference} [reference] +* @param {wikibase.datamodel.Reference|null} [reference] * @return {wikibase.datamodel.Reference|null|undefined} -* -* @throws {Error} when trying to set the value to something different that a -* `wikibase.datamodel.Reference` object. */ value: function( reference ) { if( reference ) { - if( !( reference instanceof wb.datamodel.Reference ) ) { - throw new Error( 'Value has to be an instance of wikibase.datamodel.Reference' ); - } - this._reference = reference; - return; + this.option( 'value', reference ); } var snakList = new wb.datamodel.SnakList(); @@ -263,10 +225,10 @@ } } ); - if( this._reference || snakList.length ) { + if( this.options.value || snakList.length ) { return new wb.datamodel.Reference( snakList, - this._reference ? this._reference.getHash() : undefined + this.options.value ? this.options.value.getHash() : undefined ); } @@ -321,7 +283,9 @@ this._trigger( 'afterstopediting', null, [ dropValue ] ); } else { this._saveReferenceApiCall() - .done( function( savedObject ) { + .do
[MediaWiki-commits] [Gerrit] referenceview: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190452 Change subject: referenceview: Updated documentation .. referenceview: Updated documentation Change-Id: I48750831d152a494555b0b637bb68112d6cfa1b0 --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js 1 file changed, 95 insertions(+), 71 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/190452/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 0b44434..ff359af 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -9,48 +9,64 @@ var PARENT = $.ui.TemplatedWidget; /** - * View for displaying and editing Wikibase Statements. - * @since 0.4 + * View for displaying and editing `wikibase.datamodel.Reference` objects. + * @see wikibase.datamodel.Reference + * @class jQuery.wikibase.referenceview * @extends jQuery.ui.TemplatedWidget + * @since 0.4 + * @licence GNU GPL v2+ + * @author H. Snater < mediaw...@snater.com > * - * @option statementGuid {string} (REQUIRED) The GUID of the statement the reference belongs to. + * @constructor * - * @option entityStore {wikibase.store.EntityStore} - * - * @option valueViewBuilder {wikibase.ValueViewBuilder} - * - * @option referencesChanger {wikibase.entityChangers.ReferencesChanger} - * - * @option helpMessage {string} End-user message explaining how to use the referenceview widget. The - * message is most likely to be used inside the tooltip of the toolbar corresponding to - * the referenceview. - * Default: mw.msg( 'wikibase-claimview-snak-new-tooltip' ) - * - * @event afterstartediting: Triggered after having started the referenceview's edit mode. - *(1) {jQuery.Event} - * - * @event stopediting: Triggered when stopping the referenceview's edit mode. - *(1) {jQuery.Event} - *(2) {boolean} If true, the value from before edit mode has been started will be reinstated - *(basically a cancel/save switch). - * - * @event afterstopediting: Triggered after having stopped the referenceview's edit mode. - *(1) {jQuery.Event} - *(2) {boolean} If true, the value from before edit mode has been started will be reinstated - *(basically a cancel/save switch). - * - * @event change: Triggered whenever the referenceview's content is changed. - *(1) {jQuery.Event} event - * - * @event toggleerror: Triggered when an error occurred or is resolved. - *(1) {jQuery.Event} event - *(2) {wikibase.api.RepoApiError|undefined} RepoApiError object if an error occurred, undefined if - *the current error state is resolved. + * @param {Object} options + * @param {wikibase.datamodel.Reference|null} options.value + * @param {string} options.statementGuid + *The GUID of the `Statement` the `Reference` represented by the widget instance belongs to. + * @param {wikibase.store.EntityStore} options.entityStore + *Required for dynamically gathering `Entity`/`Property` information. + * @param {wikibase.ValueViewBuilder} options.valueViewBuilder + *Required by the `snakview` interfacing a `snakview` "value" `Variation` to + *`jQuery.valueview`. + * @param {wikibase.entityChangers.ReferencesChanger} options.referencesChanger + *Required for saving the `Reference` represented by the widget instance. + * @param {string} [options.helpMessage=mw.msg( 'wikibase-claimview-snak-new-tooltip' )] + *End-user message explaining how to interact with the widget. The message is most likely to + *be used inside the tooltip of the toolbar corresponding to the widget. + */ +/** + * @event afterstartediting + * Triggered after having started the widget's edit mode and edit mode has been rendered. + * @param {jQuery.Event} event + */ +/** + * @event stopediting + * Triggered when stopping the widget's edit mode, immediately before re-drawing. + * @param {jQuery.Event} event + * @param {boolean} dropValue + *Whether the widget's value will be reset to the one from before starting edit mode. + */ +/** + * @event afterstopediting + * Triggered after having stopped the widget's edit mode and non-edit mode is redrawn. + * @param {boolean} dropValue + *Whether the widget's value has been be reset to the one from before starting edit mode. + */ +/** + * @event change + * Triggered whenever the `Reference` represented by the widget is changed. + * @param {jQuery.Event} event + */ +/** + * @event toggleerror + * Triggered when an error occurred or has been resolved. + * @param {jQuery.Event} event + * @param {wikibase.api.RepoApiError|undefined} RepoApiError + *Object if an error occur
[MediaWiki-commits] [Gerrit] referenceview: Refactored value() - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190453 Change subject: referenceview: Refactored value() .. referenceview: Refactored value() As to the common widget pattern, value() now returns "undefined" when setting a value. Change-Id: Ib36fbfb720a60361c107fab2b347f78d12259dca --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js 1 file changed, 22 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/53/190453/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index ff359af..ccdbdb8 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -240,36 +240,37 @@ * represented by the widget. * * @param {wikibase.datamodel.Reference} [reference] -* @return {wikibase.datamodel.Reference|null} +* @return {wikibase.datamodel.Reference|null|undefined} * * @throws {Error} when trying to set the value to something different that a * `wikibase.datamodel.Reference` object. */ value: function( reference ) { - if ( reference ) { - if ( !( reference instanceof wb.datamodel.Reference ) ) { + if( reference ) { + if( !( reference instanceof wb.datamodel.Reference ) ) { throw new Error( 'Value has to be an instance of wikibase.datamodel.Reference' ); } this._reference = reference; - return this._reference; - } else { - var snakList = new wb.datamodel.SnakList(); - - $.each( this.$listview.data( 'listview' ).value(), function() { - var snakListForProperty = this.value(); - if( snakListForProperty ) { - snakList.merge( snakListForProperty ); - } - } ); - - if ( this._reference ) { - return new wb.datamodel.Reference( snakList || [], this._reference.getHash() ); - } else if ( snakList.length ) { - return new wb.datamodel.Reference( snakList ); - } else { - return null; - } + return; } + + var snakList = new wb.datamodel.SnakList(); + + $.each( this.$listview.data( 'listview' ).value(), function() { + var snakListForProperty = this.value(); + if( snakListForProperty ) { + snakList.merge( snakListForProperty ); + } + } ); + + if( this._reference || snakList.length ) { + return new wb.datamodel.Reference( + snakList, + this._reference ? this._reference.getHash() : undefined + ); + } + + return null; }, /** -- To view, visit https://gerrit.wikimedia.org/r/190453 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib36fbfb720a60361c107fab2b347f78d12259dca Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] referenceview: Using listview.value() - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190443 Change subject: referenceview: Using listview.value() .. referenceview: Using listview.value() Change-Id: Iccef189bbd450add404d9717394dee9be0bd7199 --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 2 files changed, 28 insertions(+), 46 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/43/190443/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 490f2c1..0b44434 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -228,17 +228,14 @@ this._reference = reference; return this._reference; } else { - var listview = this.$listview.data( 'listview' ), - lia = listview.listItemAdapter(), - snaklistviews = this.$listview.data( 'listview' ).items(), - snakList = new wb.datamodel.SnakList(); + var snakList = new wb.datamodel.SnakList(); - for( var i = 0; i < snaklistviews.length; i++ ) { - var curSnakList = lia.liInstance( snaklistviews.eq( i ) ).value(); - if( curSnakList ) { - snakList.merge( curSnakList ); + $.each( this.$listview.data( 'listview' ).value(), function() { + var snakListForProperty = this.value(); + if( snakListForProperty ) { + snakList.merge( snakListForProperty ); } - } + } ); if ( this._reference ) { return new wb.datamodel.Reference( snakList || [], this._reference.getHash() ); @@ -259,13 +256,9 @@ return; } - var listview = this.$listview.data( 'listview' ), - lia = listview.listItemAdapter(), - $snaklistviews = listview.items(); - - for( var i = 0; i < $snaklistviews.length; i++ ) { - lia.liInstance( $snaklistviews.eq( [i] ) ).startEditing(); - } + $.each( this.$listview.data( 'listview' ).value(), function() { + this.startEditing(); + } ); this._attachEditModeEventHandlers(); @@ -404,44 +397,29 @@ * @return {boolean} */ isValid: function() { - var listview = this.$listview.data( 'listview' ), - lia = listview.listItemAdapter(), - $snaklistviews = listview.items(); - - for( var i = 0; i < $snaklistviews.length; i++ ) { - if( !lia.liInstance( $snaklistviews.eq( i ) ).isValid() ) { - return false; + var isValid = true; + $.each( this.$listview.data( 'listview' ).value(), function() { + if( !this.isValid() ) { + isValid = false; } - } - - return true; + return isValid; + } ); + return isValid; }, /** -* Returns whether the referenceview's current value matches the value it has been initialized -* with. +* Returns whether the `referenceview`'s current value matches the value it has been initialized +* with by checking the `Reference`'s `Snak`s. * @since 0.5 * * @return {boolean} */ isInitialValue: function() { - var listview = this.$listview.data( 'listview' ), - lia = listview.listItemAdapter(), - $snaklistviews = listview.items(), - snakList = new wb.datamodel.SnakList(); - - // Generate a SnakList object featuring all current reference snaks to be able to compare it - // to the SnakList object the referenceview has been initialized with: - if( $snaklistviews.length ) { - for( var i = 0; i < $snaklistviews.length; i++ ) { - var snakview = lia.liInstance( $snaklistviews.eq( i ) ); - if( snakview.value() ) { - snakList.merge( snakview.value() ); -
[MediaWiki-commits] [Gerrit] referenceview: Fixed overridden event bindings - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190441 Change subject: referenceview: Fixed overridden event bindings .. referenceview: Fixed overridden event bindings Change-Id: I8aa4cb360df0440cc8c31be27e9b5d5ab1a8c38c --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js 2 files changed, 20 insertions(+), 20 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/41/190441/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 7b293e2..37ac3d3 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -146,11 +146,6 @@ } ); this._listview = this.$listview.data( 'listview' ); - // Some who actually want to get the listview's events are listening on referenceview*, - // others who do not want to get the events of this listview are listening on - // listview*. - // FIXME: Rather fix the event bindings - this._listview.widgetEventPrefix = 'referenceview'; this._updateReferenceHashClass( this.value() ); }, @@ -164,7 +159,7 @@ var changeEvents = [ 'snakviewchange.' + this.widgetName, 'snaklistviewchange.' + this.widgetName, - 'referenceviewafteritemmove.' + this.widgetName, + 'listviewafteritemmove.' + this.widgetName, 'listviewitemadded.' + this.widgetName, 'listviewitemremoved.' + this.widgetName ]; @@ -200,7 +195,7 @@ var events = [ 'snakviewchange.' + this.widgetName, 'snaklistviewchange.' + this.widgetName, - 'referenceviewafteritemmove.' + this.widgetName, + 'listviewafteritemmove.' + this.widgetName, 'listviewitemadded.' + this.widgetName, 'listviewitemremoved.' + this.widgetName, this.options.listItemAdapter.prefixedEvent( 'stopediting.' + this.widgetName ) diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js index bce99f7..f2b89be 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js @@ -11,9 +11,9 @@ id: 'referenceview-snakview', selector: '.wikibase-statementview-references .wikibase-referenceview', events: { - 'snakviewafterstartediting snakviewchange referenceviewitemremoved': function( event, toolbarController ) { - var $target = $( event.target ), - $referenceview = $target.closest( ':wikibase-referenceview' ), + 'snakviewafterstartediting snakviewchange': function( event, toolbarcontroller ) { + var $snakview = $( event.target ), + $referenceview = $snakview.closest( ':wikibase-referenceview' ), referenceview = $referenceview.data( 'referenceview' ); if( !referenceview ) { @@ -21,33 +21,38 @@ } if ( event.type === 'snakviewafterstartediting' ) { - var $snaklistview = $target.closest( ':wikibase-snaklistview' ), + var $snaklistview = $snakview.closest( ':wikibase-snaklistview' ), snaklistview = $snaklistview.data( 'snaklistview' ), snakviewPropertyGroupListview = snaklistview._listview; - $target.removetoolbar( { - $container: $( '' ).appendTo( $target ) + $snakview.removetoolbar( { + $container: $( '' ).appendTo( $snakview ) } ) .on( 'removetoolbarremove.removetoolbar', function( event ) { - if( event.target === $target.get( 0 ) ) { - snakviewPropertyGroupListview.removeItem( $target ); + if( event.target ===
[MediaWiki-commits] [Gerrit] referenceview: Removed internal listview caching - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190442 Change subject: referenceview: Removed internal listview caching .. referenceview: Removed internal listview caching Caching listview and its listItemAdapter is prone to errors as the listview might get regenerated and the cached reference needs to be updated on every occasion. Even more, the concept of caching the listItemAdapater as option is conceptually wrong. listview instance and listItemAdapter should always be retrieved from the $listview node. Change-Id: I843a44a470f1da133c522230e4791b21e4f898ed --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js 2 files changed, 67 insertions(+), 60 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/42/190442/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 37ac3d3..490f2c1 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -91,12 +91,6 @@ _isInEditMode: false, /** -* Shortcut to the listview widget used by the referenceview to manage the snaklistview widgets. -* @type {$.wikibase.listview} -*/ - _listview: null, - - /** * @see $.wikibase.snaklistview._create * * @throws {Error} if any required option is not specified. @@ -115,8 +109,9 @@ if ( this.option( 'value' ) ) { this._reference = this.option( 'value' ); - // Overwrite the value since listItemAdapter is the snakview prototype which requires a - // wb.datamodel.SnakList object for initialization: + // Overwrite the value since listItemAdapter is the snaklistview prototype which + // requires a wb.datamodel.SnakList object for initialization: + // FIXME: Do not overwrite the value this._initialSnakList = this._reference.getSnaks(); this.options.value = this._initialSnakList.getGroupedSnakLists(); } @@ -125,27 +120,21 @@ this._initialSnakList = new wb.datamodel.SnakList(); } - if( !this.options.listItemAdapter ) { - this.options.listItemAdapter = new $.wikibase.listview.ListItemAdapter( { + this.$listview.listview( { + listItemAdapter: new $.wikibase.listview.ListItemAdapter( { listItemWidget: $.wikibase.snaklistview, newItemOptionsFn: function( value ) { return { value: value || undefined, singleProperty: true, - dataTypeStore: self.option( 'dataTypeStore' ), - entityStore: self.option( 'entityStore' ), - valueViewBuilder: self.option( 'valueViewBuilder' ) + dataTypeStore: self.options.dataTypeStore, + entityStore: self.options.entityStore, + valueViewBuilder: self.options.valueViewBuilder }; } - } ); - } - - this.$listview.listview( { - listItemAdapter: this.options.listItemAdapter, + } ), value: this.option( 'value' ) } ); - - this._listview = this.$listview.data( 'listview' ); this._updateReferenceHashClass( this.value() ); }, @@ -154,7 +143,8 @@ * Attaches event listeners needed during edit mode. */ _attachEditModeEventHandlers: function() { - var self = this; + var self = this, + lia = this.$listview.data( 'listview' ).listItemAdapter(); var changeEvents = [ 'snakviewchange.' + this.widgetName, @@ -173,14 +163,14 @@ snaklistview = $snaklistview.data( 'snaklistview' ); if( snaklistview && !snaklistview.value() ) { - self._listview.removeItem( snaklistview.element ); + self.$listview.d
[MediaWiki-commits] [Gerrit] Updated SetClaim documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/190199 Change subject: Updated SetClaim documentation .. Updated SetClaim documentation Change-Id: I065ee86dab4c96226448aa18620782a6062f6bf0 --- M repo/i18n/en.json M repo/i18n/qqq.json M repo/includes/api/SetClaim.php 3 files changed, 6 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/99/190199/1 diff --git a/repo/i18n/en.json b/repo/i18n/en.json index a5fe18f..7bc265c 100644 --- a/repo/i18n/en.json +++ b/repo/i18n/en.json @@ -568,14 +568,15 @@ "apihelp-wbsetaliases-example-2": "Add Foo and Bar to the list of English aliases for the entity with ID Q1", "apihelp-wbsetaliases-example-3": "Remove Foo and Bar from the list of English aliases for the entity with ID Q1", "apihelp-wbsetaliases-example-4": "Remove Foo from the list of English aliases for the entity with ID Q1 while adding Bar to it", - "apihelp-wbsetclaim-description": "Creates or updates an entire Claim.", - "apihelp-wbsetclaim-param-claim": "Claim serialization", + "apihelp-wbsetclaim-description": "Creates or updates an entire Statement or Claim.", + "apihelp-wbsetclaim-param-claim": "Statement or Claim serialization", "apihelp-wbsetclaim-param-index": "The index within the entity's list of claims\/statements to move the claim\/statement to. Optional. Be aware that when setting an index that specifies a position not next to a clam\/statement whose main snak does not feature the same property, the whole group of claims\/statements whose main snaks feature the same property is moved. When not provided, an existing claim\/statement will stay in place while a new claim\/statement will be appended to the last claim\/statement whose main snak features the same property.", "apihelp-wbsetclaim-param-summary": "Summary for the edit.\nWill be prepended by an automatically generated comment. The length limit of the\nautocomment together with the summary is 260 characters. Be aware that everything above that\nlimit will be cut off.", "apihelp-wbsetclaim-param-baserevid": "The numeric identifier for the revision to base the modification on.\nThis is used for detecting conflicts during save.", "apihelp-wbsetclaim-param-bot": "Mark this edit as bot\nThis URL flag will only be respected if the user belongs to the group \"bot\".", "apihelp-wbsetclaim-example-1": "Set the claim with the given ID to property P1 with a string value of \"City\"", "apihelp-wbsetclaim-example-2": "Set the claim with the given ID to property P1 with a string value of \"City\" and move the claim to the topmost position within the entity's subgroup of claims that feature the main snak property P1. In addition, move the whole subgroup to the top of all subgroups aggregated by property.", + "apihelp-wbsetclaim-example-3": "Set the Statement with the given ID to Property P1 with a string value of \"City\" and set the Statement's References to a single Reference featuring the string value \"The Economy of Cities\" assigned to the Property P2.", "apihelp-wbsetclaimvalue-description": "Sets the value of a Wikibase claim.", "apihelp-wbsetclaimvalue-param-claim": "A GUID identifying the claim", "apihelp-wbsetclaimvalue-param-snaktype": "The type of the snak", diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json index b1f520d..a64d4fe 100644 --- a/repo/i18n/qqq.json +++ b/repo/i18n/qqq.json @@ -601,6 +601,7 @@ "apihelp-wbsetclaim-param-bot": "{{doc-apihelp-param|wbsetclaim|bot}}", "apihelp-wbsetclaim-example-1": "{{doc-apihelp-example|wbsetclaim}}", "apihelp-wbsetclaim-example-2": "{{doc-apihelp-example|wbsetclaim}}", + "apihelp-wbsetclaim-example-3": "{{doc-apihelp-example|wbsetclaim}}", "apihelp-wbsetclaimvalue-description": "{{doc-apihelp-description|wbsetclaimvalue}}", "apihelp-wbsetclaimvalue-param-claim": "{{doc-apihelp-param|wbsetclaimvalue|claim}}", "apihelp-wbsetclaimvalue-param-snaktype": "{{doc-apihelp-param|wbsetclaimvalue|snaktype}}", diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php index a836044..4df9b0d 100644 --- a/repo/includes/api/SetClaim.php +++ b/repo/includes/api/SetClaim.php @@ -174,6 +174,8 @@ => 'apihelp-wbsetclaim-example-1', 'action=wbsetclaim&claim={"id":"Q2$5627445f-43cb-ed6d-3adb-760e85bd17ee","type":"claim","mainsnak":{"snaktype":"value","property":"P1","datavalue":{"value":"City","type":"string"}}}&index=0' => 'apihelp-wbsetclaim-example-2', + 'action=wbsetclaim&claim={"id":"Q2$5627445f-43cb-ed6d-3adb-760e85bd17ee","type":"statement","mainsnak":{"snaktype":"value","property":"P1","datavalue":{"value":"City","ty
[MediaWiki-commits] [Gerrit] statementview: Fixed removing qualifier snaklistview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189935 Change subject: statementview: Fixed removing qualifier snaklistview .. statementview: Fixed removing qualifier snaklistview Change-Id: If1bc2f2c0e80d97979cf154e00805fbd5088f1d6 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/35/189935/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index 440bb81..1814258 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -312,7 +312,7 @@ var $snaklistview = $( event.target ).closest( ':wikibase-snaklistview' ), snaklistview = $snaklistview.data( 'snaklistview' ); - if( !snaklistview.value() ) { + if( !snaklistview.value().length ) { self._qualifiers.removeItem( snaklistview.element ); } } ); -- To view, visit https://gerrit.wikimedia.org/r/189935 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If1bc2f2c0e80d97979cf154e00805fbd5088f1d6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] statementview: Allow adding qualifiers when adding a statement - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189936 Change subject: statementview: Allow adding qualifiers when adding a statement .. statementview: Allow adding qualifiers when adding a statement Change-Id: I015b3022570180a3e9d8d9a4fde6aada6bd4d4d5 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js M lib/resources/wikibase.css 2 files changed, 14 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/36/189936/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index 1814258..17dad73 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -139,17 +139,6 @@ _qualifiers: null, /** -* Caches the `SnakList` of the qualifiers the `statementview` has been initialized with. The -* qualifiers are split into groups featuring the same `Property`. Removing one of those groups -* results in losing the reference to those qualifiers. Therefore, `_initialQualifiers` is used -* to rebuild the list of qualifiers when cancelling and is used to query whether the qualifiers -* represent the initial state. -* @property {wikibase.datamodel.SnakList} -* @private -*/ - _initialQualifiers: null, - - /** * @property {wikibase.entityChangers.ReferencesChanger} * @private */ @@ -174,10 +163,6 @@ } PARENT.prototype._create.call( this ); - - this._initialQualifiers = this.options.value - ? this.options.value.getClaim().getQualifiers() - : new wb.datamodel.SnakList(); this._referencesChanger = this.options.entityChangersFactory.getReferencesChanger(); @@ -488,11 +473,13 @@ : this.option( 'predefined' ).mainSnak || null ); - // TODO: Allow adding qualifiers when adding a new statement. - if( this.options.value && ( this.isInEditMode() || this._initialQualifiers.length ) ) { - this._createQualifiersListview( this.options.value.getClaim().getQualifiers() ); + if( this.isInEditMode() ) { + this._createQualifiersListview( + this.options.value + ? this.options.value.getClaim().getQualifiers() + : new wb.datamodel.SnakList() + ); } - this._createReferences( this.options.value ); return $.Deferred().resolve().promise(); @@ -520,7 +507,7 @@ } } - if( !qualifiers.equals( this._initialQualifiers ) ) { + if( !qualifiers.equals( this.options.value.getClaim().getQualifiers().length ) ) { return false; } } @@ -703,11 +690,6 @@ if( this._qualifiers ) { snaklistviews = this._qualifiers.value(); - if( !dropValue ) { - // When saving the qualifier snaks, reset the initial qualifiers to the new ones. - this._initialQualifiers = new wb.datamodel.SnakList(); - } - if( snaklistviews.length ) { for( i = 0; i < snaklistviews.length; i++ ) { snaklistviews[i].stopEditing( dropValue ); @@ -716,10 +698,6 @@ // Remove snaklistview from qualifier listview if no snakviews are left in // that snaklistview: this._qualifiers.removeItem( snaklistviews[i].element ); - } else if ( !dropValue ) { - // Gather all the current snaks in a single SnakList to set to reset the - // initial qualifiers: - this._initialQualifiers.merge( snaklistviews[i].value() ); } } } @@ -730,9 +708,11 @@ // the "add qualifier" toolbar. this._destroyQualifiersListView(); - if( this._initialQualifiers.length > 0 ) { + var qualifiers = this.options.value ? this.options.value.getClaim().getQualifi
[MediaWiki-commits] [Gerrit] labelview: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189727 Change subject: labelview: Updated documentation .. labelview: Updated documentation Change-Id: Ia334e5fe3368fd1cb2f823d21148cd73fa72518a --- M lib/resources/jquery.wikibase/jquery.wikibase.labelview.js 1 file changed, 25 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/27/189727/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js index bc8d473..080d780 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js @@ -1,32 +1,29 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < mediaw...@snater.com > - */ ( function( $, mw, wb ) { 'use strict'; var PARENT = $.ui.EditableTemplatedWidget; /** - * Manages a label. + * Displays and allows editing of a `wikibase.datamodel.Term` action as an `Entity`'s label. * @since 0.5 + * @class jQuery.wikibase.labelview * @extends jQuery.ui.EditableTemplatedWidget + * @licence GNU GPL v2+ + * @author H. Snater < mediaw...@snater.com > * - * @option {wikibase.datamodel.Term} value + * @constructor * - * @option {string} [helpMessage] - * Default: mw.msg( 'wikibase-label-input-help-message' ) - * - * @option {wikibase.entityChangers.LabelsChanger} labelsChanger - * - * @option {string} entityId - * - * @option {boolean} [showEntityId] - * Default: false + * @param {Object} options + * @param {wikibase.datamodel.Term} options.value + * @param {string} [options.helpMessage=mw.msg( 'wikibase-label-input-help-message' )] + * @param {wikibase.entityChangers.LabelsChanger} options.labelsChanger + * @param {string} options.entityId + * @param {boolean} [options.showEntityId=false] */ $.widget( 'wikibase.labelview', PARENT, { /** -* @see jQuery.ui.TemplatedWidget.options +* @inheritdoc +* @protected */ options: { template: 'wikibase-labelview', @@ -47,7 +44,8 @@ }, /** -* @see jQuery.ui.TemplatedWidget._create +* @inheritdoc +* @protected * * @throws {Error} if a required option is not specified properly. */ @@ -87,7 +85,7 @@ }, /** -* @see jQuery.ui.TemplatedWidget.destroy +* @inheritdoc */ destroy: function() { if( this.isInEditMode() ) { @@ -185,21 +183,25 @@ }, /** -* @return {boolean} +* @inheritdoc */ isValid: function() { return true; }, /** -* @return {boolean} +* @inheritdoc */ isInitialValue: function() { return this.value().equals( this.options.value ); }, /** -* @see jQuery.ui.TemplatedWidget._setOption +* @inheritdoc +* @protected +* +* @throws {Error} when trying to set the widget's value to something other than a +* `wikibase.datamodel.Term` instance. */ _setOption: function( key, value ) { if( key === 'value' && !( value instanceof wb.datamodel.Term ) ) { @@ -216,7 +218,7 @@ }, /** -* Gets/Sets the widget's value. +* @inheritdoc * * @param {wikibase.datamodel.Term} [value] * @return {wikibase.datamodel.Term|undefined} @@ -238,7 +240,7 @@ }, /** -* @see jQuery.ui.TemplatedWidget.focus +* @inheritdoc */ focus: function() { if( this.isInEditMode() ) { -- To view, visit https://gerrit.wikimedia.org/r/189727 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia334e5fe3368fd1cb2f823d21148cd73fa72518a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] labelview: inherit from EditableTemplatedWidget - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189725 Change subject: labelview: inherit from EditableTemplatedWidget .. labelview: inherit from EditableTemplatedWidget Change-Id: I0f97b8bb067934613e7ed24c7e8fbc02b9b966ed --- M lib/resources/jquery.wikibase/jquery.wikibase.labelview.js M lib/resources/jquery.wikibase/resources.php 2 files changed, 29 insertions(+), 95 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/25/189725/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js index a4a09d4..a7a5f91 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js @@ -5,7 +5,7 @@ ( function( $, mw, wb ) { 'use strict'; - var PARENT = $.ui.TemplatedWidget; + var PARENT = $.ui.EditableTemplatedWidget; /** * Manages a label. @@ -47,14 +47,9 @@ }, /** -* @type {boolean} -*/ - _isInEditMode: false, - - /** * @see jQuery.ui.TemplatedWidget._create * -* @throws {Error} if required parameters are not specified properly. +* @throws {Error} if a required option is not specified properly. */ _create: function() { if( @@ -62,7 +57,7 @@ || !this.options.entityId || !this.options.labelsChanger ) { - throw new Error( 'Required parameter(s) missing' ); + throw new Error( 'Required option not specified properly' ); } var self = this; @@ -87,7 +82,7 @@ PARENT.prototype._create.call( this ); if( this.$text.text() === '' ) { - this._draw(); + this.draw(); } }, @@ -95,7 +90,7 @@ * @see jQuery.ui.TemplatedWidget.destroy */ destroy: function() { - if( this._isInEditMode ) { + if( this.isInEditMode() ) { var self = this; this.element.one( this.widgetEventPrefix + 'afterstopediting', function( event ) { @@ -109,10 +104,11 @@ }, /** -* Main draw routine. +* @inheritdoc */ - _draw: function() { + draw: function() { var self = this, + deferred = $.Deferred(), languageCode = this.options.value.getLanguageCode(), labelText = this.options.value.getText(); @@ -120,7 +116,7 @@ labelText = null; } - if( this.options.showEntityId && !( this._isInEditMode && labelText ) ) { + if( this.options.showEntityId && !( this.isInEditMode() && labelText ) ) { this.$entityId.text( mw.msg( 'parentheses', this.options.entityId ) ); } else { this.$entityId.empty(); @@ -128,9 +124,9 @@ this.element[labelText ? 'removeClass' : 'addClass']( 'wb-empty' ); - if( !this._isInEditMode ) { + if( !this.isInEditMode() ) { this.$text.text( labelText || mw.msg( 'wikibase-label-empty' ) ); - return; + return deferred.resolve().promise(); } var $input = $( '' ); @@ -157,84 +153,41 @@ } this.$text.empty().append( $input ); + + return deferred.resolve().promise(); }, /** -* Starts the widget's edit mode. +* @inheritdoc +* @protected */ - startEditing: function() { - if( this._isInEditMode ) { - return; - } - this.element.addClass( 'wb-edit' ); - this._isInEditMode = true; - this._draw(); - this._trigger( 'afterstartediting' ); - }, - - /** -* Stops the widget's edit mode. -* -* @param {boolean} dropValue -*/ - stopEditing: function( dropValue ) { - var self = this; - - if( !this._isInEditMode ) { - return; - } else if( ( !this.isValid() || this.isInitialValue() ) && !dropValue ) { - return; - } else if( dropValue ) { - this._afterStopEditing( dropValue ); - return; - } - - this.disable(); - - this._trigger( 'stopediting', null, [dropValue] ); + _save: function() { + var deferred = $.Deferred
[MediaWiki-commits] [Gerrit] label-/descriptionview Removed obsolete _isBeingEdited member - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189722 Change subject: label-/descriptionview Removed obsolete _isBeingEdited member .. label-/descriptionview Removed obsolete _isBeingEdited member The "isBeingEdited" state was removed when switching from dedicated edit mode for label and description to the entityterms edit mode. Change-Id: Iea61304029d223727684c9526eeb52bafc60c1bd --- M lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js M lib/resources/jquery.wikibase/jquery.wikibase.labelview.js 2 files changed, 9 insertions(+), 49 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/22/189722/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js b/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js index ebf5b1c..e993e23 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js @@ -36,7 +36,7 @@ '' // toolbar ], templateShortCuts: { - '$text': '.wikibase-descriptionview-text' + $text: '.wikibase-descriptionview-text' }, value: null, inputNodeName: 'TEXTAREA', @@ -48,11 +48,6 @@ * @type {boolean} */ _isInEditMode: false, - - /** -* @type {boolean} -*/ - _isBeingEdited: false, /** * @see jQuery.ui.TemplatedWidget._create @@ -165,27 +160,15 @@ }, /** -* Switches to editable state. -*/ - toEditMode: function() { - if( this._isInEditMode ) { - return; - } - - this._isInEditMode = true; - this._draw(); - }, - - /** * Starts the widget's edit mode. */ startEditing: function() { - if( this._isBeingEdited ) { + if( this._isInEditMode ) { return; } this.element.addClass( 'wb-edit' ); - this.toEditMode(); - this._isBeingEdited = true; + this._isInEditMode = true; + this._draw(); this._trigger( 'afterstartediting' ); }, @@ -196,8 +179,6 @@ */ stopEditing: function( dropValue ) { var self = this; - - dropValue = dropValue && this._isBeingEdited; if( !this._isInEditMode ) { return; @@ -243,7 +224,6 @@ } this.element.removeClass( 'wb-edit' ); - this._isBeingEdited = false; this._isInEditMode = false; this._draw(); diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js index df9d58d..a4a09d4 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js @@ -37,8 +37,8 @@ '' // toolbar ], templateShortCuts: { - '$text': '.wikibase-labelview-text', - '$entityId': '.wikibase-labelview-entityid' + $text: '.wikibase-labelview-text', + $entityId: '.wikibase-labelview-entityid' }, value: null, helpMessage: mw.msg( 'wikibase-label-input-help-message' ), @@ -50,11 +50,6 @@ * @type {boolean} */ _isInEditMode: false, - - /** -* @type {boolean} -*/ - _isBeingEdited: false, /** * @see jQuery.ui.TemplatedWidget._create @@ -165,27 +160,15 @@ }, /** -* Switches to editable state. -*/ - toEditMode: function() { - if( this._isInEditMode ) { - return; - } - - this._isInEditMode = true; - this._draw(); - }, - - /** * Starts the widget's edit mode. */ startEditing: function() { - if( this._isBeingEdited ) { + if( this._isInEditMode ) { return; } this.element.addClass( 'wb-edit' ); - this.toEditMode(); - this._isBeingEdited = true; + this._isInEditMode = true; + this._draw(); this._trigger( 'afterstartediting' ); }, @@ -196,8 +179,6 @@ */ stopEditing: function( dropValue ) { var self = this; - - dropValue = dropValue && this._isBeingEdited; if( !thi
[MediaWiki-commits] [Gerrit] aliasesview: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189717 Change subject: aliasesview: Updated documentation .. aliasesview: Updated documentation Change-Id: I91eac37e0132c9f2f6fdbffc824f096533b0d43e --- M lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js 1 file changed, 32 insertions(+), 22 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/17/189717/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js b/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js index 2f6cef2..e694790 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js @@ -1,27 +1,28 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < mediaw...@snater.com > - */ ( function( $, mw, wb ) { 'use strict'; var PARENT = $.ui.EditableTemplatedWidget; /** - * Manages aliases. - * @since 0.5 + * Displays and allows editing of `wikibase.datamodel.MultiTerm` objects. + * @see wikibase.datamodel.MultiTerm + * @class jQuery.wikibase.aliasesview * @extends jQuery.ui.EditableTemplatedWidget + * @since 0.5 + * @licence GNU GPL v2+ + * @author H. Snater < mediaw...@snater.com > * - * @option {wikibase.datamodel.MultiTerm} value + * @constructor * - * @option {string} [helpMessage] - * Default: mw.msg( 'wikibase-aliases-input-help-message' ) - * - * @option {wikibase.entityChangers.AliasesChanger} aliasesChanger + * @param {Object} options + * @param {wikibase.datamodel.MultiTerm} options.value + * @param {string} [options.helpMessage=mw.msg( 'wikibase-aliases-input-help-message' )] + * @param {wikibase.entityChangers.AliasesChanger} aliasesChanger */ $.widget( 'wikibase.aliasesview', PARENT, { /** -* @see jQuery.ui.EditableTemplatedWidget.options +* @inheritdoc +* @protected */ options: { template: 'wikibase-aliasesview', @@ -39,14 +40,17 @@ }, /** -* @see jQuery.ui.TemplatedWidget._create +* @inheritdoc +* @protected +* +* @throws {Error} if a required option is not specified properly. */ _create: function() { if( !( this.options.value instanceof wb.datamodel.MultiTerm ) || !this.options.aliasesChanger ) { - throw new Error( 'Required option(s) missing' ); + throw new Error( 'Required option not specified properly' ); } PARENT.prototype._create.call( this ); @@ -75,7 +79,7 @@ }, /** -* @see jQuery.ui.EditableTemplatedWidget.draw +* @inheritdoc */ draw: function() { this.$list.off( '.' + this.widgetName ); @@ -104,7 +108,8 @@ }, /** -* Creates and initializes the tagadata widget. +* Creates and initializes the `jQuery.ui.tagadata` widget. +* @private */ _initTagadata: function() { var self = this; @@ -158,28 +163,33 @@ }, /** -* @see jQuery.ui.EditableTemplatedWidget.save +* @inheritdoc +* @protected */ _save: function() { return this.options.aliasesChanger.setAliases( this.value() ); }, /** -* @see jQuery.ui.EditableTemplatedWidget.isValid +* @inheritdoc */ isValid: function() { return true; }, /** -* @see jQuery.ui.EditableTemplatedWidget.isValid +* @inheritdoc */ isInitialValue: function() { return this.value().equals( this.options.value ); }, /** -* @see jQuery.ui.TemplatedWidget._setOption +* @inheritdoc +* @protected +* +* @throws {Error} when trying to set the widget's value to something other than a +* `wikibase.datamodel.MultiTerm` instance. */ _setOption: function( key, value ) { if( key === 'value' && !( value instanceof wb.datamodel.MultiTerm ) ) { @@ -196,7 +206,7 @@ }, /** -* Gets/Sets the widget's value. +* @inheritdoc * * @param {wikibase.datamodel.MultiTerm} [value] * @return {wikibase.datamodel.MultiTerm|undefined} @@ -222,7 +232,7 @@ }, /** -* @see jQuery.ui.TemplatedWidget.focus +* @inheritdoc */ focus: function() { if( this.isInEditMode() ) { -- To view, visit https://gerrit.wikimedia.org/r/189717 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91eac37e0132c9f2f6fdbffc824f09
[MediaWiki-commits] [Gerrit] Added "noime" class to site id input - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189705 Change subject: Added "noime" class to site id input .. Added "noime" class to site id input _88417 Change-Id: I9212b4dd7b1868fa7acf92c57ed2a0277214bcb0 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js 1 file changed, 6 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/05/189705/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js index 2b59c3c..6d6593f 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js @@ -247,10 +247,10 @@ } } - var $pageNameInput = $( '', { - placeholder: mw.msg( 'wikibase-sitelink-page-edit-placeholder' ), - dir: dir - } ).pagesuggester( pageNameInputOptions ); + var $pageNameInput = $( '' ) + .attr( 'placeholder', mw.msg( 'wikibase-sitelink-page-edit-placeholder' ) ) + .attr( 'dir', dir ) + .pagesuggester( pageNameInputOptions ); var pagesuggester = $pageNameInput.data( 'pagesuggester' ); @@ -270,7 +270,8 @@ return; } - var $siteIdInput = $( '' ) + var $siteIdInput = $( '' ) + .addClass( 'noime' ) .attr( 'placeholder', mw.msg( 'wikibase-sitelink-site-edit-placeholder' ) ) .siteselector( { source: self.options.getAllowedSites -- To view, visit https://gerrit.wikimedia.org/r/189705 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9212b4dd7b1868fa7acf92c57ed2a0277214bcb0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] snakview: Refactored drawing mechanism - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/189018 Change subject: snakview: Refactored drawing mechanism .. snakview: Refactored drawing mechanism - untangled draw() / drawProperty() relationship moving Property specific logic out of draw() - drawProperty() does not (re)render when previously generated HTML is detected - Property and Snak type are not (re)rendered when they are locked and there previously generated HTML is detected. - Made updateVariation() public. There is no sense in being able to (re)draw the Variation without being able to update it. - Removed parameter from updateVariation() as it is supposed to always reflect the current value. - Removed parameter from drawProperty as it is supposed to always reflect the current value. - 88425 Change-Id: If45c707c08ba710fe5fec456fef29c2b60586dae --- M lib/resources/jquery.wikibase/snakview/snakview.js M lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js 2 files changed, 112 insertions(+), 61 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/18/189018/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index 1eb5eb9..2d7fecc 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -162,7 +162,8 @@ this._cachedValues = {}; - this.value( this.options.value ); + this.updateVariation(); + this.draw(); if( this.option( 'autoStartEditing' ) && !this.snak() ) { // If no Snak is represented, offer UI to build one. @@ -197,10 +198,7 @@ var response = PARENT.prototype._setOption.apply( this, arguments ); if( key === 'value' ) { - value = this.value(); - - this._updateVariation( value ); - + this.updateVariation(); this.draw(); } else if( key === 'disabled' ) { var propertySelector = this._getPropertySelector(), @@ -253,7 +251,7 @@ // remove out-dated variations if( self._variation ) { self.drawSnakTypeSelector(); - self._updateVariation( self.value() ); + self.updateVariation(); self.drawVariation(); self._trigger( 'change' ); } @@ -265,7 +263,7 @@ ); self.options.entityStore.get( entityId ).done( function( entity ) { - self._updateVariation( self.value() ); + self.updateVariation(); self.drawSnakTypeSelector(); self.drawVariation(); @@ -640,18 +638,15 @@ }, /** -* Checks whether the `Snak` type has been changed by the user and will build a new `Variation` -* object for that type if necessary. -* @private -* @since 0.4 -* -* @param {Object} value (In)complete `Snak` serialization. +* Updates the `Variation` according to the widget's current value. +* @since 0.5 */ - _updateVariation: function( value ) { - var variationsFactory = $.wikibase.snakview.variations, + updateVariation: function() { + var value = this.value(), + propertyId = value ? value.property : null, snakType = value ? value.snaktype : null, - VariationConstructor = snakType ? variationsFactory.getVariation( snakType ) : null, - propertyId = value ? value.property : null; + variationsFactory = $.wikibase.snakview.variations, + VariationConstructor = snakType ? variationsFactory.getVariation( snakType ) : null; if( this._variation && ( !propertyId || this._variation.constructor !== VariationConstructor ) @@ -701,82 +696,134 @@ }, /** -* Renders the `snakview`'s current state considering edit mode, current value, etc.. +* (Re)renders the widget. * @since 0.4 */ draw: function() { - var self = this, - value = this.value(), - propertyId = value ? value.property : null; - - // NOTE: Order of these shouldn't matter; If for any reasons draw functions start changing - // the outcome of the variation (or Snak type), then something must be incredibly wrong! -
[MediaWiki-commits] [Gerrit] jquery.ui.TemplatedWidget: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188999 Change subject: jquery.ui.TemplatedWidget: Updated documentation .. jquery.ui.TemplatedWidget: Updated documentation Change-Id: Ia429a42253e5c8e586bcf06e4ef8a76932798061 --- M repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js 1 file changed, 64 insertions(+), 57 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/99/188999/1 diff --git a/repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js b/repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js index 584a24e..4cb1666 100644 --- a/repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js +++ b/repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js @@ -1,76 +1,62 @@ -/** - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( $ ) { 'use strict'; var PARENT = $.Widget; /** -* Base prototype for all widgets which use the mw.wbTemplate templating system to create a -* basic DOM structure for internal usage. -* -* @constructor +* Base prototype for all widgets using the `mw.wbTemplate` templating system. +* Uses `jQuery.fn.applyTemplate`. +* @see mediaWiki.WbTemplate +* @class jQuery.ui.TemplatedWidget * @abstract * @extends jQuery.Widget +* @uses jQuery.fn * @since 0.4 +* @licence GNU GPL v2+ +* @author Daniel Werner < daniel.wer...@wikimedia.de > * -* @option template {string} Name of a template to use rather than the default. Of course, the -* given template has to be fully compatible to the default one. This means that should -* have all required template parameters and classes used to identify certain nodes. -* The template should have a structure with a single root node which will then be -* replaced by the Widget's subject node. +* @constructor * -* @option templateParams {Array} Parameters given to the template on its initial construction. -* A parameter can be what is compatible with wm.wbTemplate but can also be a function -* which will be executed in the widget's context and provide the parameter's value by -* its return value. -* -* @option templateShortCuts {Object} A map pointing from the name of a field of the Widget -* object which should act as a short cut to a node within the widget's template. The -* location of the target node has to be given as a valid jQuery query expression. e.g. -* 'li.example-class > .foo'. -* When setting this as option at Widget initialization, this should match the selectors -* of a custom template. The used fields should stick to what is defined in the widget's -* default options definition. -* -* @option [encapsulate=false] {boolean} Whether non-native `jQuery.Widget` events shall be -* triggered on the widget's node only and not bubble up the DOM tree (using -* `jQuery.triggerHandler()` instead of `jQuery.trigger()`). -* -* NOTE: the template options have been fields in the prototype before. It makes kind of sense -* to make them available in the options though. An issue with having 'templateShortCuts' -* as a field was that inheritance would not be possible with the jQuery Widget system -* since only options will get a true copy by $.widget while other objects will be -* modified on the base prototype. Our workaround for this only worked for one level of -* inheritance (doing the copy manually in the prototype's constructor, can't define the -* constructor of the new prototype created by jQuery.widget() though). -* +* @param {Object} options +* @param {string} options.template +*Name of a template to use. The template should feature a single root node which will +*be replaced by the widget's subject node. +* @param {*[]} [options.templateParams] +*Parameters injected into the template on its initial construction. A parameter can be +*what is compatible with `mw.wbTemplate` but can also be a function which will be +*executed in the widget's context and provide the parameter's value by its return +*value. +* @param {Object} [options.templateShortCuts] +*A map pointing from a short-cut name to a node within the widget's template. The map +*is used during the widget creation process to automatically add members to the wi
[MediaWiki-commits] [Gerrit] Not italicizing text of pending aliases - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188990 Change subject: Not italicizing text of pending aliases .. Not italicizing text of pending aliases > 88695 Change-Id: I2802e7830ed189dc667659fff297577eadc5b218 --- M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css 1 file changed, 0 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/90/188990/1 diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css index dd8ce1a..9fa5b33 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css @@ -124,6 +124,3 @@ .wikibase-entitytermsforlanguagelistview .wikibase-entitytermsforlanguagelistview-listview .wikibase-entitytermsforlanguageview .wikibase-entitytermsforlanguageview-aliases input:focus { border-color: #0b0080; } -.wikibase-entitytermsforlanguagelistview .wikibase-entitytermsforlanguagelistview-listview .wikibase-entitytermsforlanguageview .wikibase-entitytermsforlanguageview-aliases li.tagadata-choice-modified .tagadata-label-text { - font-style: italic; -} -- To view, visit https://gerrit.wikimedia.org/r/188990 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2802e7830ed189dc667659fff297577eadc5b218 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Removed ineffective "widgetEventPrefix" overwrites - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188989 Change subject: Removed ineffective "widgetEventPrefix" overwrites .. Removed ineffective "widgetEventPrefix" overwrites Event handler registration was adjusted in I5b42f92ae351b41cafcd7d04e691c3a634bc6e4e already. Change-Id: Icce7a222ce52fe7267708c574d3eec06c446afed --- M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js 2 files changed, 0 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/89/188989/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index 3a8999c..0e7bf69 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -19,11 +19,6 @@ */ $.widget( 'wikibase.itemview', PARENT, { /** -* @see jQuery.Widget.widgetEventPrefix -*/ - widgetEventPrefix: $.wikibase.entityview.widgetName, - - /** * @property {jQuery} * @protected */ diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js index a00207b..9102a7d 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js @@ -18,11 +18,6 @@ */ $.widget( 'wikibase.propertyview', PARENT, { /** -* @see jQuery.Widget.widgetEventPrefix -*/ - widgetEventPrefix: $.wikibase.entityview.widgetName, - - /** * @property {jQuery} * @protected */ -- To view, visit https://gerrit.wikimedia.org/r/188989 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icce7a222ce52fe7267708c574d3eec06c446afed Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] itemview/propertyview: Split off initialization from creation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188984 Change subject: itemview/propertyview: Split off initialization from creation .. itemview/propertyview: Split off initialization from creation The change splits off the initialization from the creation routine in itemview and propertyview. _create should be used to only create DOM structure for TemplatedWidget can initialize template short-cuts. Initialization of sub-widgets is to be done in _init. > 88699 Change-Id: Ie3b09bb780c28198ccf534239ae48323395a39ab --- M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js M repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js 4 files changed, 52 insertions(+), 28 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/84/188984/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index db89d4c..782960b 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -107,13 +107,12 @@ }, /** -* Main initialization actually calling parent's _create(). -* @see jQuery.ui.TemplatedWidget._create +* @inheritdoc * @protected * * @throws {Error} if a required options is missing. */ - _initEntityview: function() { + _init: function() { if( !this.options.value || !this.options.languages @@ -130,7 +129,7 @@ this._initEntityTerms(); - PARENT.prototype._create.call( this ); + PARENT.prototype._init.call( this ); this._attachEventHandlers(); }, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index 3a8999c..a0fbb0a 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -34,20 +34,32 @@ * @protected */ _create: function() { + this.$statements = $( '.wikibase-statementgrouplistview', this.element ).first(); + if( this.$statements.length === 0 ) { + this.$statements = $( '' ).appendTo( this.element ); + } + + this.$siteLinks = $( '.wikibase-sitelinkgrouplistview', this.element ); + + if( !this.$siteLinks.length ) { + this.$siteLinks = $( '' ).appendTo( this.element ); + } + }, + + /** +* @inheritdoc +* @protected +*/ + _init: function() { this._initStatements(); this._initSiteLinks(); - this._initEntityview(); + PARENT.prototype._init.call( this ); }, /** * @protected */ _initStatements: function() { - this.$statements = $( '.wikibase-statementgrouplistview', this.element ).first(); - if( this.$statements.length === 0 ) { - this.$statements = $( '' ).appendTo( this.element ); - } - this.$statements .statementgrouplistview( { value: this.options.value.getStatements(), @@ -71,16 +83,9 @@ */ _initSiteLinks: function() { var self = this, - value = []; - - this.$siteLinks = $( '.wikibase-sitelinkgrouplistview', this.element ); - - if( this.$siteLinks.length ) { - value = scrapeSiteLinks( this.$siteLinks, this.options.value.getSiteLinks() ); - } else { - this.$siteLinks = $( '' ).appendTo( this.element ); - value = orderSiteLinksByGroup( this.options.value.getSiteLinks() ); - } + value = $( '.wikibase-sitelinkgrouplistview', this.element ).length + ? scrapeSiteLinks( this.$siteLinks, this.options.value.getSiteLinks() ) + : orderSiteLinksByGroup( this.options.value.getSiteLinks() ); this.$siteLinks.sitelinkgrouplistview( { value: value, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js index a00207b..1f90858 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js @@ -39,15 +39,27 @@ * @protected
[MediaWiki-commits] [Gerrit] snakview.ViewState: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188048 Change subject: snakview.ViewState: Updated documentation .. snakview.ViewState: Updated documentation Change-Id: I646eaba6753a8fdfc899fc54d4d4b2495668371d --- M lib/resources/jquery.wikibase/snakview/snakview.ViewState.js 1 file changed, 22 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/48/188048/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js b/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js index ac1e685..822ac7d 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js @@ -1,7 +1,3 @@ -/** - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( $ ) { 'use strict'; @@ -9,15 +5,20 @@ $.wikibase.snakview = $.wikibase.snakview || {}; /** -* Allows to receive information about a related snakview object but doesn't provide functions -* to actively change the view. It serves as a state object to inform subsystems of the view's -* current status. Those subsystems should not have full access to the entire view though since -* interaction in both directions would very likely mess things up. +* Interface to a `jQuery.wikibase.snakview` instance that allows querying the `snakview` for +* information as well as updating the `snakview`. Does not provide functions to actively change +* the view but acts as a state object. +* @see jQuery.wikibase.snakview +* @class jQuery.wikibase.snakview.ViewState +* @since 0.4 +* @licence GNU GPL v2+ +* @author Daniel Werner < daniel.wer...@wikimedia.de > * * @constructor -* @since 0.4 * * @param {jQuery.wikibase.snakview} snakView +* +* @throws {Error} if a required parameter is not specified properly. */ var SELF = $.wikibase.snakview.ViewState = function WbSnakviewViewState( snakView ) { if( !( snakView instanceof $.wikibase.snakview ) ) { @@ -27,14 +28,14 @@ }; $.extend( SELF.prototype, { /** -* The widget object whose status is represented. -* @type jQuery.wikibase.snakview +* The `snakview` the `ViewState` is interfacing to. +* @property {jQuery.wikibase.snakview} */ _view: null, /** -* Notifies the snakview of a status update. -* @since 0.4 +* Notifies the `snakview` of a status update. +* @see jQuery.wikibase.snakview.updateStatus * * @param {string} status */ @@ -44,6 +45,8 @@ /** * @see jQuery.wikibase.snakview.isInEditMode +* +* @return {boolean} */ isInEditMode: function() { return this._view.isInEditMode(); @@ -51,6 +54,8 @@ /** * @see jQuery.wikibase.snakview.propertyId +* +* @return {string} */ propertyId: function() { return this._view.propertyId(); @@ -58,6 +63,8 @@ /** * @see jQuery.wikibase.snakview.snakType +* +* @return {string} */ snakType: function() { return this._view.snakType(); @@ -65,6 +72,8 @@ /** * @see jQuery.wikibase.snakview.isDisabled +* +* @return {boolean} */ isDisabled: function() { return this._view.isDisabled(); -- To view, visit https://gerrit.wikimedia.org/r/188048 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I646eaba6753a8fdfc899fc54d4d4b2495668371d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] snakview.variations*: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188047 Change subject: snakview.variations*: Updated documentation .. snakview.variations*: Updated documentation Change-Id: I5ab898aff6fbbeb1e30770d18d0c240a4f9f9aeb --- M lib/resources/jquery.wikibase/snakview/snakview.variations.NoValue.js M lib/resources/jquery.wikibase/snakview/snakview.variations.SomeValue.js M lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js M lib/resources/jquery.wikibase/snakview/snakview.variations.Variation.js M lib/resources/jquery.wikibase/snakview/snakview.variations.js 5 files changed, 184 insertions(+), 186 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/47/188047/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.variations.NoValue.js b/lib/resources/jquery.wikibase/snakview/snakview.variations.NoValue.js index 110b1db..534def6 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.variations.NoValue.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.variations.NoValue.js @@ -1,8 +1,3 @@ -/** - * - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( mw, wb, $ ) { 'use strict'; @@ -10,16 +5,21 @@ PARENT = MODULE.Variation; /** -* Required snakview variation for displaying and creating PropertyNoValue Snaks. Only displays -* a message, doesn't offer any additional user interface interaction. -* -* @constructor +* `snakview` `Variation` for displaying and creating `wikibase.datamodel.PropertyNoValueSnak`s. +* Only displays a message, does not offer any additional user interface interaction. +* @see jQuery.wikibase.snakview +* @see wikibase.datamodel.PropertyNoValueSnak +* @class jQuery.wikibase.snakview.variations.NoValue * @extends jQuery.wikibase.snakview.variations.Variation * @since 0.4 +* @licence GNU GPL v2+ +* @author Daniel Werner < daniel.wer...@wikimedia.de > +* +* @constructor */ MODULE.variation( wb.datamodel.PropertyNoValueSnak, PARENT, { /** -* @see jQuery.wikibase.snakview.variations.Variation.draw +* @inheritdoc */ draw: function() { // display same message in edit and non-edit mode! diff --git a/lib/resources/jquery.wikibase/snakview/snakview.variations.SomeValue.js b/lib/resources/jquery.wikibase/snakview/snakview.variations.SomeValue.js index a2b5d47..78fcb9c 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.variations.SomeValue.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.variations.SomeValue.js @@ -1,8 +1,3 @@ -/** - * - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( mw, wb, $ ) { 'use strict'; @@ -10,16 +5,22 @@ PARENT = MODULE.Variation; /** -* Required snakview variation for displaying and creating PropertySomeValue Snaks. Only displays -* a message, doesn't offer any additional user interface interaction. -* -* @constructor +* `snakview` `Variation` for displaying and creating +* `wikibase.datamodel.PropertySomeValueSnak`s. Only displays a message, does not offer any +* additional user interface interaction. +* @see jQuery.wikibase.snakview +* @see wikibase.datamodel.PropertySomeValueSnak +* @class jQuery.wikibase.snakview.varaiations.SomeValue * @extends jQuery.wikibase.snakview.variations.Variation * @since 0.4 +* @licence GNU GPL v2+ +* @author Daniel Werner < daniel.wer...@wikimedia.de > +* +* @constructor */ MODULE.variation( wb.datamodel.PropertySomeValueSnak, PARENT, { /** -* @see jQuery.wikibase.snakview.variations.Variation.draw +* @inheritdoc */ draw: function() { // display same message in edit and non-edit mode! diff --git a/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js b/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js index cf7b40b..e0ae443 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js @@ -1,7 +1,3 @@ -/** - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( mw, wb, $, dv ) { 'use strict'; @@ -9,31 +5,39 @@ PARENT = MODULE.Variation; /** -* Required snakview variation for displaying and creating PropertyValueSnak Snaks. Serves a -* valueview input widget
[MediaWiki-commits] [Gerrit] Removed obsolete snakview.isDisabled() - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188049 Change subject: Removed obsolete snakview.isDisabled() .. Removed obsolete snakview.isDisabled() Change-Id: I790d514121f04b8a70f25ccdd1bb27ea78d86065 --- M lib/resources/jquery.wikibase/snakview/snakview.ViewState.js M lib/resources/jquery.wikibase/snakview/snakview.js 2 files changed, 1 insertion(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/49/188049/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js b/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js index 822ac7d..5d32806 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.ViewState.js @@ -76,7 +76,7 @@ * @return {boolean} */ isDisabled: function() { - return this._view.isDisabled(); + return this._view.option( 'disabled' ); } } ); diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index 5fd11c9..570e4b3 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -220,14 +220,6 @@ }, /** -* @return {boolean} -*/ - isDisabled: function() { - // Function is required by snakview.ViewState. - return this.option( 'disabled' ); - }, - - /** * Returns an input element with initialized `entityselector` for selecting entities. * @private * -- To view, visit https://gerrit.wikimedia.org/r/188049 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I790d514121f04b8a70f25ccdd1bb27ea78d86065 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] SnakTypeSelector: Updated code documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188039 Change subject: SnakTypeSelector: Updated code documentation .. SnakTypeSelector: Updated code documentation Change-Id: I0c5904898e6b3c1340304352e220426380b69356 --- M lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js 1 file changed, 40 insertions(+), 44 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/39/188039/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js index 2440629..e17787b 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js @@ -1,54 +1,56 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < mediaw...@snater.com > - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( mw, $ ) { 'use strict'; var PARENT = $.Widget; /** -* Selector for choosing a Snak type. This will display all Snak types which can be displayed -* by jQuery.snakview (this is the case if there is a jQuery.snakview.variations.Variation -* object registered for a certain type of Snak). -* -* NOTE: Because this is tightly bound to the snakview variations, this can't be considered an -* independent wiki an thus should be considered part of the jQuery.wikibase.snakview rather -* than as a stand alone widget. -* There could also be some sort of generic menu widget. Menu items could be defined via some -* array of plain objects with label/key fields and this widget would be obsolete since all -* available variations could be given to such a widget without much overhead in code. This -* would also allow for an independent snak type selector widget which does not only list -* Snaks which are available as variation objects. -* +* Selector for choosing a `Snak` type offering to select from a list of all `Snak` types which +* a `jQuery.snakview.variations.Variation` is registered for and, thus, can be displayed by a +* `jQuery.wikibase.snakview`. +* Because of being tightly bound to the `jQuery.wikibase.snakview.variations`, the widget is +* considered part of the `jQuery.wikibase.snakview` rather than being a stand-alone widget. +* @see jQuery.wikibase.snakview +* @see jQuery.wikibase.snakview.variations +* @see jQuery.wikibase.snakview.variations.Variation +* @see wikibase.datamodel.Snak +* @class jQuery.wikibase.snakview.SnakTypeSelector +* @extends jQuery.Widget * @since 0.4 +* @licence GNU GPL v2+ +* @author H. Snater < mediaw...@snater.com > +* @author Daniel Werner < daniel.wer...@wikimedia.de > * -* @event change Triggered when the snak type changed. -*(1) {jQuery.Event} +* @constructor +*/ + /** +* @event change +* Triggered when the `Snak` type changed. +* @param {jQuery.Event} event */ $.widget( 'wikibase.SnakTypeSelector', PARENT, { /** -* Icon node. -* @type {jQuery} +* @property {jQuery} +* @private */ - $icon: null, + _$icon: null, /** -* The menu's Widget object -* @type Object +* @property {jQuery.ui.menu} +* @private */ _menu: null, /** -* Will hold the function for removing global listeners if there are any. If not, this -* will hold an empty function instead. -* @type Function +* The function for removing global event listeners, if there are any. Empty function if +* no gloabel event listeners are registered. +* @property {Function} +* @private */ _unbindGlobalListenersFn: $.noop, /** * @see jQuery.Widget._create +* @protected */ _create: function() { var self = this, @@ -100,7 +102,7 @@ $( window ).on( 'resize.' + widgetName, degrade ); } ); - this.$icon = $( '' ) + this._$icon = $( '' ) .addClass( 'ui-icon ui-icon-snaktypeselector' ) .appendTo( this.element ); @@ -123,7 +125,7 @@ this._menu.destroy();
[MediaWiki-commits] [Gerrit] SnakTypeSelector: Removed unnecessary code - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188040 Change subject: SnakTypeSelector: Removed unnecessary code .. SnakTypeSelector: Removed unnecessary code Change-Id: I0d92bf0889b04de32e24e0a13b2b1f505f8dc292 --- M lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js 1 file changed, 16 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/40/188040/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js index e17787b..ee326fe 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js @@ -59,19 +59,15 @@ this._menu = $menu.data( 'menu' ); + this._hoverable( this.element ); + // TODO: add a title message this.element .addClass( 'ui-state-default ' + this.widgetBaseClass ) - .on( 'mouseover.' + widgetName, function( event ) { - self.element.addClass( 'ui-state-hover' ); - } ) - .on( 'mouseout.' + widgetName, function( event ) { - self.element.removeClass( 'ui-state-hover' ); - } ) .on( 'click.' + widgetName, function( event ) { // don't show menu if selector is disabled! // otherwise, simply toggle menu's visibility - if( self.isDisabled() || $menu.is( ':visible' ) ) { + if( self.options.disabled || $menu.is( ':visible' ) ) { $menu.hide(); return; } @@ -127,7 +123,7 @@ this._$icon.remove(); - this.element.removeClass( 'ui-state-default ui-state-hover ' + this.widgetBaseClass ); + this.element.removeClass( 'ui-state-default ' + this.widgetBaseClass ); // remove event listeners responsible for closing this instance's menu: this._unbindGlobalListenersFn(); @@ -136,28 +132,19 @@ }, /** -* @see jQuery.Widget.disable +* @see jQuery.Widget._setOption +* @protected +* +* @param {string} key +* @param {*} value +* @return {jQuery.Widget} */ - disable: function() { - this._menu.element.hide(); - this.element.removeClass( 'ui-state-active ui-state-hover' ); - this.element.addClass( 'ui-state-disabled' ); - return PARENT.prototype.disable.call( this ); - }, - - /** -* @see jQuery.Widget.enable -*/ - enable: function() { - this.element.removeClass( 'ui-state-disabled' ); - return PARENT.prototype.enable.call( this ); - }, - - /** -* Returns whether the widget is currently disabled. -*/ - isDisabled: function() { - return this.option( 'disabled' ); + _setOption: function( key, value ) { + if( key === 'disabled' ) { + this._menu.element.hide(); + this.element.removeClass( 'ui-state-active' ); + } + return PARENT.prototype._setOption.apply( this, arguments ); }, /** -- To view, visit https://gerrit.wikimedia.org/r/188040 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0d92bf0889b04de32e24e0a13b2b1f505f8dc292 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added Special page to set label, description and aliases at ... - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/187423 Change subject: Added Special page to set label, description and aliases at once .. Added Special page to set label, description and aliases at once Change-Id: I9c23eca9f7303c3be04e3ac2c07f45779f1a0746 --- M repo/Wikibase.i18n.alias.php M repo/Wikibase.php M repo/i18n/en.json M repo/i18n/qqq.json M repo/includes/View/EntityTermsView.php M repo/includes/specials/SpecialModifyEntity.php A repo/includes/specials/SpecialSetLabelDescriptionAliases.php A repo/tests/phpunit/includes/specials/SpecialSetLabelDescritionAliasesTest.php 8 files changed, 520 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/23/187423/1 diff --git a/repo/Wikibase.i18n.alias.php b/repo/Wikibase.i18n.alias.php index ba42ce4..f73679f 100644 --- a/repo/Wikibase.i18n.alias.php +++ b/repo/Wikibase.i18n.alias.php @@ -25,6 +25,7 @@ 'SetLabel' => array( 'SetLabel' ), 'SetDescription' => array( 'SetDescription' ), 'SetAliases' => array( 'SetAliases' ), + 'SetLabelDescriptionAliases' => array( 'SetLabelDescriptionAliases' ), 'SetSiteLink' => array( 'SetSiteLink' ), 'MergeItems' => array( 'MergeItems', 'MergeItem' ), 'EntitiesWithoutLabel' => array( 'EntitiesWithoutLabel' ), diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 7010a28..3b3052f 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -150,6 +150,7 @@ $wgSpecialPages['SetLabel'] = 'Wikibase\Repo\Specials\SpecialSetLabel'; $wgSpecialPages['SetDescription'] = 'Wikibase\Repo\Specials\SpecialSetDescription'; $wgSpecialPages['SetAliases'] = 'Wikibase\Repo\Specials\SpecialSetAliases'; + $wgSpecialPages['SetLabelDescriptionAliases'] = 'Wikibase\Repo\Specials\SpecialSetLabelDescriptionAliases'; $wgSpecialPages['SetSiteLink'] = 'Wikibase\Repo\Specials\SpecialSetSiteLink'; $wgSpecialPages['EntitiesWithoutLabel'] = array( 'Wikibase\Repo\Specials\SpecialEntitiesWithoutPageFactory', 'newSpecialEntitiesWithoutLabel' ); $wgSpecialPages['EntitiesWithoutDescription'] = array( 'Wikibase\Repo\Specials\SpecialEntitiesWithoutPageFactory', 'newSpecialEntitiesWithoutDescription' ); diff --git a/repo/i18n/en.json b/repo/i18n/en.json index a5fe18f..04ccc62 100644 --- a/repo/i18n/en.json +++ b/repo/i18n/en.json @@ -184,6 +184,13 @@ "wikibase-setaliases-label": "Aliases:", "wikibase-setaliases-submit": "Set aliases", "wikibase-setaliases-warning-remove": "Do you really want to remove all aliases of [[$1]]?", + "special-setlabeldescriptionaliases": "Set label, description and aliases", + "wikibase-setlabeldescriptionaliases-introfull": "You are setting label, description and aliases in $2 for [[$1]].", + "wikibase-setlabeldescriptionaliases-intro": "This form allows you to set label, description and aliases of an entity. You need to provide the id of the entity (e.g. Q23), a language code (e.g. \"en\") as well as label, description and aliases to set to. Several aliases are separated by a pipe (|) character.", + "wikibase-setlabeldescriptionaliases-label-label": "Label:", + "wikibase-setlabeldescriptionaliases-description-label": "Description:", + "wikibase-setlabeldescriptionaliases-aliases-label": "Aliases:", + "wikibase-setlabeldescriptionaliases-submit": "Set label, description and aliases", "special-setsitelink": "Set a site link", "wikibase-setsitelink-introfull": "You are setting the site link of $2 for [[$1]].", "wikibase-setsitelink-intro": "This form allows you to set the site link of an item. You need to provide the id of the item (e.g. Q23), a site id (e.g. \"enwiki\") and the site link to set to.", diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json index 930f9f5..6434671 100644 --- a/repo/i18n/qqq.json +++ b/repo/i18n/qqq.json @@ -210,6 +210,13 @@ "wikibase-setaliases-label": "Label for the input field to type the aliases to set the entity to.\n{{Identical|Alias}}", "wikibase-setaliases-submit": "Label for the button that activates the action.", "wikibase-setaliases-warning-remove": "A warning message to ask the user if he wants to remove all aliases.\n\nParameters:\n* $1 - the id that links to the entity", + "special-setlabel": "{{doc-special|SetLabelAliasesDescription}}\nThe special page allows the user to set an entity's label, description and aliases in a particular language.", + "wikibase-setlabel-introfull": "Intro text when label, description and aliases are to be set. Parameters:\n* $1 - the
[MediaWiki-commits] [Gerrit] Fixed sitelinklistview QUnit test - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/187342 Change subject: Fixed sitelinklistview QUnit test .. Fixed sitelinklistview QUnit test As of change Iee90bfa54e8fdb0692d4bbe21ef2fd2d60aaccb8, sitelinklistview encapsulates its listview using TemplatedWidget's "encapsulate" option. Hence, listview events should not bubble up to the sitelinklistview node anymore. Change-Id: I0a325f639dccd0dfee61c5de83ba75f763ebc787 --- M lib/tests/qunit/jquery.wikibase/jquery.wikibase.sitelinklistview.tests.js 1 file changed, 10 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/42/187342/1 diff --git a/lib/tests/qunit/jquery.wikibase/jquery.wikibase.sitelinklistview.tests.js b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.sitelinklistview.tests.js index 968e9e9..da52e4b 100644 --- a/lib/tests/qunit/jquery.wikibase/jquery.wikibase.sitelinklistview.tests.js +++ b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.sitelinklistview.tests.js @@ -354,11 +354,19 @@ var $sitelinklistview = createSitelinklistview(), sitelinklistview = $sitelinklistview.data( 'sitelinklistview' ); + sitelinklistview.$listview + .on( 'listviewenternewitem', function() { + assert.ok( + true, + 'Triggered listview\'s "enternewitem" event on the listview node.' + ); + } ); + $sitelinklistview .on( 'listviewenternewitem', function( event, $sitelinkview ) { assert.ok( - true, - 'Added listview item.' + false, + 'Triggered listview\'s "enternewitem" event on the sitelinklistview node.' ); } ) .on( 'sitelinklistviewafterstartediting', function() { -- To view, visit https://gerrit.wikimedia.org/r/187342 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a325f639dccd0dfee61c5de83ba75f763ebc787 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] statementgroupview: Fixed documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/187093 Change subject: statementgroupview: Fixed documentation .. statementgroupview: Fixed documentation Change-Id: I6b45ee0fe62418358ffae615a9f9f587f040c01d --- M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/93/187093/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js index 8db4589..0855e45 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js @@ -137,8 +137,8 @@ /** * @private * -* @param {wikibase.datamodel.StatementGroup} statementGroupSet -* @return {wikibase.datamodel.StatementList[]} +* @param {wikibase.datamodel.StatementGroupSet} statementGroupSet +* @return {wikibase.datamodel.StatementGroup[]} */ _statementGroupSetToStatementGroups: function( statementGroupSet ) { return $.map( statementGroupSet.getKeys(), function( propertyId ) { -- To view, visit https://gerrit.wikimedia.org/r/187093 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6b45ee0fe62418358ffae615a9f9f587f040c01d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Consolidated snakview value() and snak() function - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186963 Change subject: Consolidated snakview value() and snak() function .. Consolidated snakview value() and snak() function - value() accepts and returns plain objects (incomplete or complete serialization). - Serialization returned by value() does not contain fields with "null" values anymore; Instead, those fields are undefined. - snak() accepts and returns Snak objects or "null". - Actual value setting logic is moved to _setOption to comply with widget standards. - As to the current "value" option specification, options.value may be a Snak object or an (in)complete Snak serialization. Change-Id: I2a3107644a8bf95c4b3f4678a9a51858c0676bce --- M lib/resources/jquery.wikibase/snakview/snakview.js M lib/tests/qunit/jquery.wikibase/snakview/resources.php M lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js 3 files changed, 104 insertions(+), 42 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/63/186963/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index 5fd11c9..654f05d 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -27,7 +27,7 @@ *The `Snak` this `snakview` should represent initially. If omitted, an empty view will be *served, ready to take some input by the user. The value may be overwritten later, by using *the `value()` or the `snak()` function. - *Default: `{ property: null, snaktype: wikibase.datamodel.PropertyValueSnak.TYPE }` + *Default: `{ snaktype: wikibase.datamodel.PropertyValueSnak.TYPE }` * @param {Object|boolean} [options.locked=false] *Key-value pairs determining which `snakview` elements to lock from being edited by the *user. May also be a boolean value enabling/disabling all elements. If `false`, no elements @@ -83,7 +83,6 @@ '$snakTypeSelector': '.wikibase-snakview-typeselector' }, value: { - property: null, snaktype: wb.datamodel.PropertyValueSnak.TYPE }, locked: { @@ -202,7 +201,15 @@ * @protected */ _setOption: function( key, value ) { - if ( key === 'locked' && typeof value === 'boolean' ) { + if( key === 'value' ) { + if( + value !== null + && !$.isPlainObject( value ) && !( value instanceof wb.datamodel.Snak ) + ) { + throw new Error( 'The given value has to be a plain object, an instance of ' + + 'wikibase.datamodel.Snak, or null' ); + } + } else if( key === 'locked' && typeof value === 'boolean' ) { var locked = value; value = $.extend( {}, $.wikibase.snakview.prototype.options.locked ); $.each( $.wikibase.snakview.prototype.options.locked, function( k, v ) { @@ -212,7 +219,11 @@ var response = PARENT.prototype._setOption.apply( this, arguments ); - if( key === 'disabled' ) { + if( key === 'value' ) { + this._setValue( + value instanceof wb.datamodel.Snak ? this._serializeSnak( value ) : value + ); + } else if( key === 'disabled' ) { this.draw(); } @@ -512,18 +523,14 @@ * has not yet been supplied, the returned object would not have a field for the value either. * * @param {Object|wikibase.datamodel.Snak|null} [value] -* @return {wikibase.datamodel.Snak|null|undefined} `undefined` in case `value()` is called to +* @return {wikibase.datamodel.Snak|Object|undefined} `undefined` in case `value()` is called to * set the value. */ value: function( value ) { if( value === undefined ) { return this._getValue(); } - if( value !== null && typeof value !== 'object' ) { - throw new Error( 'The given value has to be a plain object, an instance of ' - + 'wikibase.datamodel.Snak, or null' ); - } - this._setValue( value instanceof wb.datamodel.Snak ? this._serializeSnak( value ) : value ); + this.option( 'value', value ); }, /** @@ -543,10 +550,16 @@ * @return {Object} */ _getValue: function() { - var value = {
[MediaWiki-commits] [Gerrit] Added snakview.value() QUnit tests - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186959 Change subject: Added snakview.value() QUnit tests .. Added snakview.value() QUnit tests As there is no use in returning "datavalue: null" in the Value variation, the "datavalue" field is not returned at all anymore in order to achieve consistency of setting and getting the snakview's value. Change-Id: I63fa416beaad65a5d71ad739e8c18fc274788166 --- M lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js M lib/tests/qunit/jquery.wikibase/snakview/resources.php M lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js 3 files changed, 61 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/59/186959/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js b/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js index e88f116..a4a6c72 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.variations.Value.js @@ -70,10 +70,7 @@ dataValue = this._valueView.value(); } - return { - // null if no value yet or if value with no suitable valueview for - datavalue: dataValue - }; + return !dataValue ? {} : { datavalue: dataValue }; }, /** diff --git a/lib/tests/qunit/jquery.wikibase/snakview/resources.php b/lib/tests/qunit/jquery.wikibase/snakview/resources.php index 5d5a314..d3cf6d0 100644 --- a/lib/tests/qunit/jquery.wikibase/snakview/resources.php +++ b/lib/tests/qunit/jquery.wikibase/snakview/resources.php @@ -22,10 +22,14 @@ 'snakview.tests.js', ), 'dependencies' => array( + 'dataTypes.DataTypeStore', 'jquery.wikibase.snakview', 'mediawiki.Title', 'wikibase.datamodel.Fingerprint', 'wikibase.datamodel.Property', + 'wikibase.datamodel.PropertyNoValueSnak', + 'wikibase.datamodel.PropertySomeValueSnak', + 'wikibase.datamodel.PropertyValueSnak', 'wikibase.datamodel.Term', 'wikibase.datamodel.TermMap', 'wikibase.serialization.SnakSerializer', diff --git a/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js b/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js index e0443e2..b8b83c4 100644 --- a/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js +++ b/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js @@ -2,7 +2,7 @@ * @licence GNU GPL v2+ * @author H. Snater < mediaw...@snater.com > */ -( function( $, QUnit, wb, mw ) { +( function( $, QUnit, wb, dt, mw ) { 'use strict'; QUnit.module( 'jquery.wikibase.snakview', QUnit.newMwEnvironment( { @@ -35,6 +35,8 @@ } }; +var snakSerializer = new wb.serialization.SnakSerializer(); + /** * @param {Object} [options={}] * @param {jQuery} [$node] @@ -44,7 +46,7 @@ options = $.extend( { entityStore: entityStore, valueViewBuilder: 'I am a ValueViewBuilder', - dataTypeStore: 'I am a DataTypeStore' + dataTypeStore: new dt.DataTypeStore() }, options || {} ); $node = $node || $( '' ).appendTo( 'body' ); @@ -88,9 +90,7 @@ ); $snakview = createSnakview( { - value: ( new wb.serialization.SnakSerializer() ).serialize( - new wb.datamodel.PropertyNoValueSnak( 'P1' ) - ) + value: snakSerializer.serialize( new wb.datamodel.PropertyNoValueSnak( 'P1' ) ) } ); snakview = $snakview.data( 'snakview' ); @@ -107,4 +107,54 @@ ); } ); -}( jQuery, QUnit, wikibase, mediaWiki ) ); +QUnit.test( 'value()', function( assert ) { + var $snakview = createSnakview(), + snakview = $snakview.data( 'snakview' ); + + assert.deepEqual( + snakview.value(), + { + property: null, + snaktype: wb.datamodel.PropertyValueSnak.TYPE + }, + 'Verified default value.' + ); + + var newValue = { + property: 'P1', + snaktype: wb.datamodel.PropertySomeValueSnak.TYPE + }; + + snakview.value( newValue ); + + assert.deepEqual( + snakview.value(), + newValue, + 'Set Snak
[MediaWiki-commits] [Gerrit] Added basic snakview QUnit tests - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186955 Change subject: Added basic snakview QUnit tests .. Added basic snakview QUnit tests Change-Id: Ib1a9c7e350aba2d9ca025352ef1e65ad11fa0539 --- M lib/tests/qunit/jquery.wikibase/resources.php A lib/tests/qunit/jquery.wikibase/snakview/resources.php A lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js 3 files changed, 150 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/55/186955/1 diff --git a/lib/tests/qunit/jquery.wikibase/resources.php b/lib/tests/qunit/jquery.wikibase/resources.php index 001db94..5492573 100644 --- a/lib/tests/qunit/jquery.wikibase/resources.php +++ b/lib/tests/qunit/jquery.wikibase/resources.php @@ -308,6 +308,7 @@ return array_merge( $modules, + include( __DIR__ . '/snakview/resources.php' ), include( __DIR__ . '/toolbar/resources.php' ) ); diff --git a/lib/tests/qunit/jquery.wikibase/snakview/resources.php b/lib/tests/qunit/jquery.wikibase/snakview/resources.php new file mode 100644 index 000..5d5a314 --- /dev/null +++ b/lib/tests/qunit/jquery.wikibase/snakview/resources.php @@ -0,0 +1,39 @@ + + * + * @codeCoverageIgnoreStart + */ +return call_user_func( function() { + + $remoteExtPathParts = explode( + DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + ); + $moduleTemplate = array( + 'localBasePath' => __DIR__, + 'remoteExtPath' => $remoteExtPathParts[1], + ); + + $resources = array( + + 'jquery.wikibase.snakview.tests' => $moduleTemplate + array( + 'scripts' => array( + 'snakview.tests.js', + ), + 'dependencies' => array( + 'jquery.wikibase.snakview', + 'mediawiki.Title', + 'wikibase.datamodel.Fingerprint', + 'wikibase.datamodel.Property', + 'wikibase.datamodel.Term', + 'wikibase.datamodel.TermMap', + 'wikibase.serialization.SnakSerializer', + 'wikibase.store.FetchedContent', + ), + ), + + ); + + return $resources; +} ); diff --git a/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js b/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js new file mode 100644 index 000..e0443e2 --- /dev/null +++ b/lib/tests/qunit/jquery.wikibase/snakview/snakview.tests.js @@ -0,0 +1,110 @@ +/** + * @licence GNU GPL v2+ + * @author H. Snater < mediaw...@snater.com > + */ +( function( $, QUnit, wb, mw ) { +'use strict'; + +QUnit.module( 'jquery.wikibase.snakview', QUnit.newMwEnvironment( { + teardown: function() { + $( '.test_snakview' ).each( function() { + var $snakview = $( this ), + snakview = $snakview.data( 'snakview' ); + + if( snakview ) { + snakview.destroy(); + } + + $snakview.remove(); + } ); + } +} ) ); + +var entityStore = { + get: function() { + return $.Deferred().resolve( new wb.store.FetchedContent( { + title: new mw.Title( 'Property:P1' ), + content: new wb.datamodel.Property( + 'P1', + 'string', + new wb.datamodel.Fingerprint( new wb.datamodel.TermMap( [ + new wb.datamodel.Term( 'en', 'P1' ) + ] ) ) + ) + } ) ); + } +}; + +/** + * @param {Object} [options={}] + * @param {jQuery} [$node] + * @return {jQuery} + */ +var createSnakview = function( options, $node ) { + options = $.extend( { + entityStore: entityStore, + valueViewBuilder: 'I am a ValueViewBuilder', + dataTypeStore: 'I am a DataTypeStore' + }, options || {} ); + + $node = $node || $( '' ).appendTo( 'body' ); + + return $node + .addClass( 'test_snakview' ) + .snakview( options ); +}; + +QUnit.test( 'Create & destroy', function( assert ) { + var $snakview = createSnakview(), + snakview = $snakview.data( 'snakview' ); + + assert.ok( + snakview instanceof $.wikibase.snakview, + 'Created widget.' + ); + + snakview.destroy(); + + assert.ok( + $snakview.data( 'snakview' ) === undefined, +
[MediaWiki-commits] [Gerrit] Fixed copyright notification - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186944 Change subject: Fixed copyright notification .. Fixed copyright notification _ 87568 Change-Id: I66b868886a4000ff73577eff315063d1ca376dd1 --- M lib/resources/wikibase.css M repo/resources/wikibase.ui.entityViewInit.js 2 files changed, 10 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/44/186944/1 diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css index 41420de..a7a4e01 100644 --- a/lib/resources/wikibase.css +++ b/lib/resources/wikibase.css @@ -66,6 +66,10 @@ background-color: #FFDFC9; } +.wikibase-copyrightnotification-container a { + cursor: pointer; +} + /** BASIC LAYOUT **/ diff --git a/repo/resources/wikibase.ui.entityViewInit.js b/repo/resources/wikibase.ui.entityViewInit.js index d39730e..2a467b2 100644 --- a/repo/resources/wikibase.ui.entityViewInit.js +++ b/repo/resources/wikibase.ui.entityViewInit.js @@ -258,14 +258,18 @@ return; } - var $message = $( '' + copyRightMessageHtml + '' ), + var $message = $( '' + copyRightMessageHtml + '' ) + .addClass( 'wikibase-copyrightnotification-container' ), $hideMessage = $( '', { text: mw.msg( 'wikibase-copyrighttooltip-acknowledge' ) } ).appendTo( $message ), editableTemplatedWidget = $origin.data( 'EditableTemplatedWidget' ); // TODO: Use notification system for copyright messages on all widgets. - if( editableTemplatedWidget ) { + if( + editableTemplatedWidget + && !( editableTemplatedWidget instanceof $.wikibase.statementview ) + ) { editableTemplatedWidget.notification( $message, 'wb-edit' ); $hideMessage.on( 'click', function( event ) { -- To view, visit https://gerrit.wikimedia.org/r/186944 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I66b868886a4000ff73577eff315063d1ca376dd1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Consolidated snaklistview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186786 Change subject: Consolidated snaklistview .. Consolidated snaklistview - snaklistview handles SnakLists only (accepts and returns nothing but a SnakList object) - As to other widget, snaklistview consistently uses "value" option to store initial value which may be retrieved via ".option( 'value' ) while the current value may be retrieved using ".value()" - Moved ".value()" setter logic to "._setOption()" - Using SnakList native "equals()" to check for initial value. Change-Id: Ib93d77c2d88f0fd5f707ce4e4276335789d4afc8 --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.snaklistview.tests.js 4 files changed, 84 insertions(+), 116 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/86/186786/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 7007d05..33efe83 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -130,7 +130,7 @@ listItemWidget: $.wikibase.snaklistview, newItemOptionsFn: function( value ) { return { - value: value || null, + value: value || new wb.datamodel.SnakList(), singleProperty: true, dataTypeStore: self.option( 'dataTypeStore' ), entityStore: self.option( 'entityStore' ), diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js index d38d51e..33e9c1a 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js @@ -17,9 +17,8 @@ * @constructor * * @param {Object} options - * @param {wikibase.datamodel.SnakList|null} [value=null] - *The `SnakList` to be displayed by this view. If `null`, the view will start edit mode upon - *initialization. + * @param {wikibase.datamodel.SnakList} value + *The `SnakList` to be displayed by this view. * @param {boolean} [singleProperty=true] *If `true`, it is assumed that the widget is filled with `Snak`s featuring a single common *property. @@ -75,20 +74,10 @@ value: null, singleProperty: false, helpMessage: mw.msg( 'wikibase-claimview-snak-new-tooltip' ), - dataTypeStore: null, entityStore: null, - valueViewBuilder: null + valueViewBuilder: null, + dataTypeStore: null }, - - /** -* The `SnakList` represented by this widget. This variable is not updated while in edit -* mode and does not contain temporary `Snak`s. To get the temporary `Snak`s, `value()` should -* be used. As soon as the `snaklistview`'s "save" operation is performed via `stopEditing()` is -* performed, this variable gets updated. -* @property {wikibase.datamodel.SnakList} -* @private -*/ - _snakList: null, /** * Short-cut to the `listview` widget used by the `snaklistview` to manage the `snakview` @@ -115,9 +104,18 @@ /** * @inheritdoc * @protected +* +* @throws {Error} if a required option is not specified properly. */ _create: function() { - this._snakList = this.option( 'value' ); + if( + !this.options.entityStore + || !this.options.valueViewBuilder + || !this.options.dataTypeStore + || !( this.options.value instanceof wb.datamodel.SnakList ) + ) { + throw new Error( 'Required option not specified properly' ); + } PARENT.prototype._create.call( this ); @@ -165,7 +163,7 @@ }; } } ), - value: ( this._snakList ) ? this._snakList.toArray() : null + value: this.options.value.toArray() } ); if( $listviewParent ) { @@ -316,40 +314,29 @@ /** * Sets a new `SnakList` or returns the current `Snak
[MediaWiki-commits] [Gerrit] snaklistview: Removed getSnakList() - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186784 Change subject: snaklistview: Removed getSnakList() .. snaklistview: Removed getSnakList() Method is unused. .value() should be used directly instead as it is done in other widgets. Change-Id: I0ae87c5be40d421aaada9c7b426aac810bcc922d --- M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js 1 file changed, 0 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/84/186784/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js index fcef284..d587d76 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js @@ -353,16 +353,6 @@ }, /** -* Returns the `SnakList` currently represented by the `snaklistview`. -* @since 0.5 -* -* @return {wikibase.datamodel.SnakList|null} -*/ - getSnakList: function() { - return this.value(); - }, - - /** * Returns whether all of the `snaklistview`'s `Snak`s are currently valid. * * @return {boolean} -- To view, visit https://gerrit.wikimedia.org/r/186784 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0ae87c5be40d421aaada9c7b426aac810bcc922d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] snaklistview: Updated documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186783 Change subject: snaklistview: Updated documentation .. snaklistview: Updated documentation Change-Id: I40e412ed30434d3a799ea0eef99811baa9f2d1ea --- M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js 1 file changed, 108 insertions(+), 116 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/83/186783/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js index f29d24a..fcef284 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js @@ -1,64 +1,68 @@ -/** - * - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - * @author H. Snater < mediaw...@snater.com > - */ ( function( mw, wb, $ ) { 'use strict'; var PARENT = $.ui.TemplatedWidget; /** - * View for displaying and editing a list of snaks (wb.datamodel.Snak objects). - * @since 0.4 + * View for displaying and editing a `wikibase.datamodel.SnakList` object. + * @see wikibase.datamodel.SnakList + * @class jQuery.wikibase.snaklistview * @extends jQuery.ui.TemplatedWidget + * @uses jQuery.wikibase.listview + * @since 0.4 + * @licence GNU GPL v2+ + * @author Daniel Werner < daniel.wer...@wikimedia.de > + * @author H. Snater < mediaw...@snater.com > * - * @option {wb.datamodel.SnakList|null} value The list of snaks displayed by this view. This should only be - * set initially. If this is null, the view will start edit mode upon initialization. - * Default: null + * @constructor * - * @option {boolean} singleProperty If set to true, it is assumed that the widget is filled with - * snakviews featuring a single property only. - * Default: false - * - * @option {string} helpMessage End-user message explaining how to use the snaklistview widget. The - * message is most likely to be used inside the tooltip of the toolbar corresponding to - * the snaklistview. - * Default: mw.msg( 'wikibase-claimview-snak-new-tooltip' ) - * - * @option {wb.store.EntityStore} entityStore - * - * @option {wikibase.ValueViewBuilder} valueViewBuilder - * - * @option {dataTypes.DataTypeStore} dataTypeStore - * - * @event afterstartediting: Triggered after having started the snaklistview's edit mode. - *(1) {jQuery.Event} - * - * @event stopediting: Triggered when stopping the snaklistview's edit mode. - *(1) {jQuery.Event} - *(2) {boolean} If true, the value from before edit mode has been started will be reinstated - *(basically a cancel/save switch). - * - * @event afterstopediting: Triggered after having stopped the snaklistview's edit mode. - *(1) {jQuery.Event} - *(2) {boolean} If true, the value from before edit mode has been started will be reinstated - *(basically a cancel/save switch). - * - * @event change: Triggered whenever the snaklistview's content is changed. - *(1) {jQuery.Event} event - * - * @event disable: Triggered whenever the snaklistview gets disabled. - *(1) {jQuery.Event} event - * - * @event enable: Triggered whenever the snaklistview gets enabled. - *(1) {jQuery.Event} event + * @param {Object} options + * @param {wikibase.datamodel.SnakList|null} [value=null] + *The `SnakList` to be displayed by this view. If `null`, the view will start edit mode upon + *initialization. + * @param {boolean} [singleProperty=true] + *If `true`, it is assumed that the widget is filled with `Snak`s featuring a single common + *property. + * @param {wikibase.store.EntityStore} options.entityStore + *Required for dynamically gathering `Entity`/`Property` information. + * @param {wikibase.ValueViewBuilder} options.valueViewBuilder + *Required by the `snakview` interfacing a `snakview` "value" `Variation` to + *`jQuery.valueview`. + * @param {dataTypes.DataTypeStore} options.dataTypeStore + *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` + *object when interacting on a "value" `Variation`. + * @param {string} [optionshelpMessage=mw.msg( 'wikibase-claimview-snak-new-tooltip' )] + *End-user message explaining how to use the `snaklistview` widget. The message is most + *likely to be used inside the tooltip of the toolbar corresponding to the `snaklistview`. + */ +/** + * @event afterstartediting + * Triggered after having started the widget's edit mode. + * @param {jQuery.Event} event + */ +/** + * @event stopediting + * Triggered when stopping the widget's edit mode. + * @param {jQuery.Event} + * @param {boolean} If `true`, the widget's value will be reset
[MediaWiki-commits] [Gerrit] Renamed wb-referenceview to wikibase-referenceview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186779 Change subject: Renamed wb-referenceview to wikibase-referenceview .. Renamed wb-referenceview to wikibase-referenceview In compliance to the common widget naming schema. Change-Id: Ic3baeb64851999a2256f54eb7918b140c51b7fb9 --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js M lib/resources/wikibase.css M repo/includes/View/ClaimHtmlGenerator.php M repo/resources/templates.php 7 files changed, 33 insertions(+), 37 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/79/186779/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 9840d6f..7007d05 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -53,13 +53,13 @@ * @see jQuery.Widget.options */ options: { - template: 'wb-referenceview', + template: 'wikibase-referenceview', templateParams: [ '', // additional css classes '' // snaklistview widget ], templateShortCuts: { - '$listview': '.wb-referenceview-listview' + $listview: '.wikibase-referenceview-listview' }, statementGuid: null, entityStore: null, @@ -533,9 +533,5 @@ } } } ); - -// We have to override this here because $.widget sets it no matter what's in -// the prototype -$.wikibase.referenceview.prototype.widgetBaseClass = 'wb-referenceview'; }( mediaWiki, wikibase, jQuery ) ); diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js index a07366e..36c5d3e 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js @@ -9,7 +9,7 @@ */ $.wikibase.toolbarcontroller.definition( 'addtoolbar', { id: 'referenceview-snakview', - selector: '.wikibase-statementview-references .wb-referenceview', + selector: '.wikibase-statementview-references .wikibase-referenceview', events: { referenceviewafterstartediting: function( event, toolbarController ) { var $referenceview = $( event.target ), diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js index f46ee13..cb49b3c 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js @@ -22,7 +22,7 @@ if( !$container.length ) { $container = $( '' ).appendTo( - $referenceview.find( '.wb-referenceview-heading' ) + $referenceview.find( '.wikibase-referenceview-heading' ) ); } diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js index 89d1239..4145d35 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js @@ -9,7 +9,7 @@ */ $.wikibase.toolbarcontroller.definition( 'removetoolbar', { id: 'referenceview-snakview', - selector: '.wikibase-statementview-references .wb-referenceview', + selector: '.wikibase-statementview-references .wikibase-referenceview', events: { 'snakviewafterstartediting snakviewchange referenceviewitemremoved': function( event, toolbarController ) { var $target = $( event.target ), diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css index 0f412e5..039aae9 100644 --- a/lib/resources/wikibase.css +++ b/lib/resources/wiki
[MediaWiki-commits] [Gerrit] Renamed wb-snakview/wb-snak to wikibase-snakview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186773 Change subject: Renamed wb-snakview/wb-snak to wikibase-snakview .. Renamed wb-snakview/wb-snak to wikibase-snakview In compliance with common widget naming schema. Change-Id: I304affdb3fabb96cae2b0f984c53dce5528b8fb5 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js M lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js M lib/resources/jquery.wikibase/snakview/snakview.js M lib/resources/jquery.wikibase/snakview/snakview.variations.js M lib/resources/jquery.wikibase/snakview/themes/default/snakview.SnakTypeSelector.css M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js M lib/resources/wikibase.css M repo/includes/View/SnakHtmlGenerator.php M repo/resources/templates.php M repo/tests/phpunit/includes/View/ClaimHtmlGeneratorTest.php M repo/tests/phpunit/includes/View/SnakHtmlGeneratorTest.php 11 files changed, 68 insertions(+), 79 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/73/186773/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js index 9246d20..fe2fd20 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js @@ -212,11 +212,12 @@ function findFirstVisibleMainSnakElement( $searchRange ) { var result = null; - // Caring about the visibility of ".wb-snak-value-container" is better than about + // Caring about the visibility of ".wikibase-snakview-value-container" is better than about // ".wikibase-statementview" or ".wikibase-statementview-mainsnak" since the label will - // align with the .wb-snak-value-container. - var $mainSnaks - = $searchRange.find( '.wikibase-statementview-mainsnak .wb-snak-value-container' ); + // align with the .wikibase-snakview-value-container. + var $mainSnaks = $searchRange.find( + '.wikibase-statementview-mainsnak .wikibase-snakview-value-container' + ); $mainSnaks.each( function( i, mainSnakNode ) { // Take first Main Snak value in viewport. If value is not fully visible in viewport, diff --git a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js index 95125a3..2647292 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js @@ -244,8 +244,4 @@ $.wikibase.snakview.SnakTypeSelector = $.wikibase.SnakTypeSelector; - // We have to override this here because $.widget sets it no matter what's in - // the prototype - $.wikibase.snakview.SnakTypeSelector.prototype.widgetBaseClass = 'wb-snaktypeselector'; - }( mediaWiki, jQuery ) ); diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index 6aec8d6..0771b69 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -75,12 +75,12 @@ * @protected */ options: { - template: 'wb-snak', + template: 'wikibase-snakview', templateParams: [ '', '', '' ], templateShortCuts: { - '$property': '.wb-snak-property', - '$snakValue': '.wb-snak-value', - '$snakTypeSelector': '.wb-snak-typeselector' + '$property': '.wikibase-snakview-property', + '$snakValue': '.wikibase-snakview-value', + '$snakTypeSelector': '.wikibase-snakview-typeselector' }, value: { property: null, @@ -932,10 +932,6 @@ return this.$property.is( ':visible' ); } } ); - -// We have to override this here because $.widget sets it no matter what's in -// the prototype -$.wikibase.snakview.prototype.widgetBaseClass = 'wb-snakview'; $.extend( $.wikibase.snakview, existingSnakview ); diff --git a/lib/resources/jquery.wikibase/snakview/snakview.variations.js b/lib/resources/jquery.wikibase/snakview/snakview.variations.js index 40391bc..e397514 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.variations.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.variations.js @@ -53,7 +53,7 @@ variationName = 'WbSnakviewVariations_' + s
[MediaWiki-commits] [Gerrit] Renamed wb-snaklistview to wikibase-snaklistview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186772 Change subject: Renamed wb-snaklistview to wikibase-snaklistview .. Renamed wb-snaklistview to wikibase-snaklistview In compliance with common widget naming schema. Change-Id: I93768b2d968950457274f44528467056e333fff9 --- M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-snakview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-snakview.js M lib/resources/wikibase.css M repo/includes/View/ClaimHtmlGenerator.php M repo/resources/templates.php 6 files changed, 34 insertions(+), 38 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/72/186772/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js index 36793b4..f29d24a 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js @@ -61,12 +61,12 @@ * @see jQuery.Widget.options */ options: { - template: 'wb-snaklistview', + template: 'wikibase-snaklistview', templateParams: [ '' // listview widget ], templateShortCuts: { - '$listview': '.wb-snaklistview-listview' + $listview: '.wikibase-snaklistview-listview' }, value: null, singleProperty: false, @@ -113,7 +113,7 @@ PARENT.prototype._create.call( this ); if ( !this.option( 'value' ) ) { - this.$listview.addClass( 'wb-snaklistview-listview-new' ); + this.$listview.addClass( 'wikibase-snaklistview-listview-new' ); } this._createListView(); @@ -562,9 +562,5 @@ } } ); - -// We have to override this here because $.widget sets it no matter what's in -// the prototype -$.wikibase.snaklistview.prototype.widgetBaseClass = 'wb-snaklistview'; }( mediaWiki, wikibase, jQuery ) ); diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-snakview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-snakview.js index d0cc953..c3936fd 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-snakview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-snakview.js @@ -100,7 +100,7 @@ // Enable "add" link when all qualifiers have been removed: var $listviewNode = $( event.target ), listview = $listviewNode.data( 'listview' ), - $snaklistviewNode = $listviewNode.closest( '.wb-snaklistview' ), + $snaklistviewNode = $listviewNode.closest( '.wikibase-snaklistview' ), snaklistview = $snaklistviewNode.data( 'snaklistview' ), addToolbar = $snaklistviewNode.data( 'addtoolbar' ); diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-snakview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-snakview.js index f7fab10..e6792ec 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-snakview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-snakview.js @@ -13,7 +13,7 @@ events: { 'snakviewafterstartediting': function( event, toolbarController ) { var $snakview = $( event.target ), - $snaklistview = $snakview.closest( '.wb-snaklistview' ), + $snaklistview = $snakview.closest( '.wikibase-snaklistview' ), snaklistview = $snaklistview.data( 'snaklistview' ); if( !snaklistview ) { diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css index 677d546..b7c380b 100644 --- a/lib/resources/wikibase.css +++ b/lib/resources/wikibase.css @@ -407,55 +407,55 @@ padding-left: 17em; } -.wikibase-statementview-qualifiers .wb-snaklistview:first-child { +.wikibase-statementview-qualifiers .wikibase-snaklistview:first-child { border-top: 1px dotted #D8D8D8; } -.wikibase
[MediaWiki-commits] [Gerrit] snaklistview: Removed NativeEventHandler - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186767 Change subject: snaklistview: Removed NativeEventHandler .. snaklistview: Removed NativeEventHandler Removed unused concept of NativeEventHandler. As the "startediting" event is not part of the common widget schema, it is removed along. Change-Id: I271a9d5a42f0f2f8180bc971b4b1094a64c64a91 --- M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js M lib/resources/jquery.wikibase/resources.php M lib/resources/jquery.wikibase/snakview/resources.php M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementview-snakview.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.snaklistview.tests.js 5 files changed, 62 insertions(+), 102 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/67/186767/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js index f9fc515..36793b4 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js @@ -33,9 +33,6 @@ * * @option {dataTypes.DataTypeStore} dataTypeStore * - * @event startediting: Triggered when starting the snaklistview's edit mode. - *(1) {jQuery.Event} - * * @event afterstartediting: Triggered after having started the snaklistview's edit mode. *(1) {jQuery.Event} * @@ -213,79 +210,70 @@ * * @return {undefined} (allows chaining widget calls) */ - startEditing: $.NativeEventHandler( 'startEditing', { - initially: function( e ) { - if( this.isInEditMode() ) { - e.cancel(); - } - }, - natively: function( e ) { - var self = this; - - $.each( this._listview.items(), function( i, item ) { - var snakview = self._lia.liInstance( $( item ) ); - snakview.startEditing(); - } ); - - this.element.addClass( 'wb-edit' ); - this._isInEditMode = true; - - this._trigger( 'afterstartediting' ); + startEditing: function() { + if( this.isInEditMode() ) { + return; } - } ), + + var self = this; + + $.each( this._listview.items(), function( i, item ) { + var snakview = self._lia.liInstance( $( item ) ); + snakview.startEditing(); + } ); + + this.element.addClass( 'wb-edit' ); + this._isInEditMode = true; + + this._trigger( 'afterstartediting' ); + }, /** -* Exits the snaklistview's edit mode. -* @since 0.4 +* Stops the widget's edit mode. * * @param {boolean} [dropValue] If true, the value from before edit mode has been started will *be reinstated - basically a cancel/save switch. "false" by default. Consider using *cancelEditing() instead. -* @return {undefined} (allows chaining widget calls) */ - stopEditing: $.NativeEventHandler( 'stopEditing', { - initially: function( e, dropValue ) { - if( !this.isInEditMode() ) { - e.cancel(); - } - - this.element.removeClass( 'wb-error' ); - }, - natively: function( e, dropValue ) { - var self = this; - - this._detachEditModeEventHandlers(); - - this.disable(); - - if ( dropValue ) { - // If the whole item was pending, remove the whole list item. This has to be - // performed in the widget using the snaklistview. - - // Re-create the list view to restore snakviews that have been removed during - // editing: - this._createListView(); - } else { - $.each( this._listview.items(), function( i, item ) { - var $item = $( item ), - snakview = self._lia.liInstance( $item ); - - snakview.stopEditing( dropValue ); - - // After saving, the property should not be editable anymore. - snakview.options.locked.property = true; - } )
[MediaWiki-commits] [Gerrit] referenceview: Removed NativeEventHandler - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186766 Change subject: referenceview: Removed NativeEventHandler .. referenceview: Removed NativeEventHandler Removed unused concept of NativeEventHandler. As the "startediting" event is not part of the common widget schema, it is removed along. Change-Id: I47090300724bd4bcacb114b7504e371a0854ec32 --- M lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js 2 files changed, 60 insertions(+), 81 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/66/186766/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js index 66422d3..9840d6f 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.referenceview.js @@ -26,9 +26,6 @@ * the referenceview. * Default: mw.msg( 'wikibase-claimview-snak-new-tooltip' ) * - * @event startediting: Triggered when starting the referenceview's edit mode. - *(1) {jQuery.Event} - * * @event afterstartediting: Triggered after having started the referenceview's edit mode. *(1) {jQuery.Event} * @@ -268,91 +265,73 @@ }, /** -* Starts the referenceview's edit mode. +* Starts the widget's edit mode. * @since 0.5 -* -* @triggers startediting -* @triggers afterstartediting */ - startEditing: $.NativeEventHandler( 'startediting', { - initially: function( e ) { - if( this.isInEditMode() ) { - e.cancel(); - } - }, - natively: function( e ) { - var $snaklistviews = this._listview.items(); - - for( var i = 0; i < $snaklistviews.length; i++ ) { - this.options.listItemAdapter.liInstance( $snaklistviews.eq( [i] ) ).startEditing(); - } - - this._attachEditModeEventHandlers(); - - this.element.addClass( 'wb-edit' ); - this._isInEditMode = true; - - this._trigger( 'afterstartediting' ); + startEditing: function() { + if( this.isInEditMode() ) { + return; } - } ), + + var $snaklistviews = this._listview.items(); + + for( var i = 0; i < $snaklistviews.length; i++ ) { + this.options.listItemAdapter.liInstance( $snaklistviews.eq( [i] ) ).startEditing(); + } + + this._attachEditModeEventHandlers(); + + this.element.addClass( 'wb-edit' ); + this._isInEditMode = true; + + this._trigger( 'afterstartediting' ); + }, /** -* Stops the referenceview's edit mode. +* Stops the widget's edit mode. * @since 0.5 -* -* @triggers stopediting -* @triggers afterstopediting */ - stopEditing: $.NativeEventHandler( 'stopediting', { - initially: function( e, dropValue ) { - if ( - !this.isInEditMode() || ( !this.isValid() || this.isInitialValue() ) && !dropValue - ) { - e.cancel(); - } - - this.element.removeClass( 'wb-error' ); - }, - natively: function( e, dropValue ) { - var self = this; - - this._detachEditModeEventHandlers(); - - this.disable(); - - if( dropValue ) { - this._stopEditingReferenceSnaks( dropValue ); - - this.enable(); - this.element.removeClass( 'wb-edit' ); - this._isInEditMode = false; - - this._trigger( 'afterstopediting', null, [ dropValue ] ); - } else { - - this._saveReferenceApiCall() - .done( function( savedObject ) { - self._stopEditingReferenceSnaks( dropValue ); - - self.enable(); - - self.element.removeClass( 'wb-edit' ); - self._isInEditMode = false; - - self._trigger( 'afterstopediting', null, [ dropValue ] ); - } ) -
[MediaWiki-commits] [Gerrit] Removed obsolete documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186765 Change subject: Removed obsolete documentation .. Removed obsolete documentation Change-Id: Icb454b864fedf7cee163893760686d14833d3a81 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 2 files changed, 2 insertions(+), 33 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/65/186765/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js index f8ce6c6..452b73d 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js @@ -122,8 +122,8 @@ this.element .on( afterStartEditingEvent, function( event ) { - // Forward "startediting" event for higher components (e.g. statementgrouplistview) to - // recognize that edit mode has been started. + // Forward "afterstartediting" event for higher components (e.g. statementgrouplistview) + // to recognize that edit mode has been started. self._trigger( 'afterstartediting' ); } ) .on( afterStopEditingEvent, function( event, dropValue ) { diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index bd61655..576a827 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -58,30 +58,6 @@ *likely to be used inside the tooltip of the toolbar corresponding to the `statementview`. */ /** - * @event startediting - * Triggered when starting the view's edit mode. - * @param {jQuery.Event} event - */ -/** - * @event afterstartediting - * Triggered after having started the view's edit mode. - * @param {jQuery.Event} event - */ -/** - * @event stopediting - * Triggered when stopping the view's edit mode. - * @param {jQuery.Event} event - * @param {boolean} dropValue If true, the value from before edit mode has been started will be - *reinstated (basically, a cancel/save switch). - */ -/** - * @event afterstopediting - * Triggered after having stopped the view's edit mode. - * @param {jQuery.Event} event - * @param {boolean} dropValue If true, the value from before edit mode has been started has been - * reinstated (basically, a cancel/save switch). - */ -/** * @event afterremove * Triggered after a `referenceview` has been remove from the `statementview`'s list of * `referenceview`s. @@ -91,13 +67,6 @@ * @event change * Triggered whenever the view's content is changed. * @param {jQuery.Event} event - */ -/** - * @event toggleerror - * Triggered when an error occurred or is resolved. - * @param {jQuery.Event} event - * @param {wikibase.api.RepoApiError} [error] `wikikibase.api.RepoApiError` object if an error - *occurred, `undefined` if the current error state is resolved. */ $.widget( 'wikibase.statementview', PARENT, { /** -- To view, visit https://gerrit.wikimedia.org/r/186765 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icb454b864fedf7cee163893760686d14833d3a81 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fixed statementview._getReferences - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186764 Change subject: Fixed statementview._getReferences .. Fixed statementview._getReferences _87567 Change-Id: Ife2be224de413fc47f290f0375f849d8ffece726 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 1 file changed, 5 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/64/186764/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index c938251..c1d3642 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -608,14 +608,15 @@ // If the statement is pending (not yet stored), the listview widget for the references is // not defined. - if ( !this._referencesListview ) { + if( !this._referencesListview ) { return references; } $.each( this._referencesListview.items(), function( i, item ) { - var referenceview = self._referenceviewLia.liInstance( $( item ) ); - if( referenceview ) { - references.push( referenceview.value() ); + var referenceview = self._referenceviewLia.liInstance( $( item ) ), + reference = referenceview ? referenceview.value() : null; + if( reference ) { + references.push( reference ); } } ); -- To view, visit https://gerrit.wikimedia.org/r/186764 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ife2be224de413fc47f290f0375f849d8ffece726 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] snaktypeselector: Remove NativeEventHandler - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186761 Change subject: snaktypeselector: Remove NativeEventHandler .. snaktypeselector: Remove NativeEventHandler Removed unused concept of NativeEventHandler. There is no (and there should be no) need for an event being triggered before changing the snak type. Change-Id: I6c4dfc7761e9c0d3cbaf43c859c4c752264c2985 --- M lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js M lib/resources/jquery.wikibase/snakview/snakview.js 2 files changed, 15 insertions(+), 28 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/61/186761/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js index 1df67eb..95125a3 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js @@ -24,16 +24,10 @@ * * @since 0.4 * -* @event change Triggered before the snak type changes -*(1) {jQuery.Event} -*(2) {string|null} The new Snak type or null if emptied -* -* @event afterchange Triggered after the snak type got changed +* @event change Triggered when the snak type changed. *(1) {jQuery.Event} */ $.widget( 'wikibase.SnakTypeSelector', PARENT, { - widgetName: 'wikibase-snaktypeselector', - /** * Icon node. * @type {jQuery} @@ -216,27 +210,20 @@ * * @param {string|null} snakType */ - _setSnakType: $.NativeEventHandler( 'change', { - initially: function( event, snakType ) { - if( this.snakType() === snakType ) { - event.cancel(); // same type selected already, no change - } - }, - natively: function( event, snakType ) { - var $menu = this._menu.element; - - // take active status from currently active Snak type list item: - $menu.children( '.ui-state-active' ).removeClass( 'ui-state-active' ); - - if( snakType !== null ) { - // set list item of new type active: - $menu.children( '.' + this.widgetBaseClass + '-menuitem-' + snakType ) - .addClass( 'ui-state-active' ); - } - - this._trigger( 'afterchange' ); + _setSnakType: function( snakType ) { + if( this.snakType() === snakType ) { + return; } - } ), + + this._menu.element.children( '.ui-state-active' ).removeClass( 'ui-state-active' ); + + if( snakType !== null ) { + this._menu.element.children( '.' + this.widgetBaseClass + '-menuitem-' + snakType ) + .addClass( 'ui-state-active' ); + } + + this._trigger( 'change' ); + }, /** * Positions the menu. diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index fc3277f..6aec8d6 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -894,7 +894,7 @@ // ...add the data information nevertheless: $anchor.data( 'snaktypeselector', selector ); - var changeEvent = ( selector.widgetEventPrefix + 'afterchange' ).toLowerCase(); + var changeEvent = ( selector.widgetEventPrefix + 'change' ).toLowerCase(); // bind user interaction on selector to snakview's state: $anchor.on( changeEvent + '.' + this.widgetName, function( event ) { -- To view, visit https://gerrit.wikimedia.org/r/186761 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6c4dfc7761e9c0d3cbaf43c859c4c752264c2985 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Updated snakview documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186760 Change subject: Updated snakview documentation .. Updated snakview documentation Unnecessary private members _entityStore and _valueViewBuilder are removed along. Change-Id: Id11bd29d23a40785288c34abb44cef76f3a605ee --- M lib/resources/jquery.wikibase/snakview/snakview.js 1 file changed, 171 insertions(+), 179 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/60/186760/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index 1cd4629..fc3277f 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -1,8 +1,3 @@ -/** - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - * @author H. Snater < mediaw...@snater.com > - */ ( function( mw, wb, $ ) { 'use strict'; @@ -17,57 +12,67 @@ var PARENT = $.ui.TemplatedWidget; /** - * View for displaying and editing Wikibase Snaks. - * @since 0.3 + * View for displaying and editing `wikibase.datamodel.Snak` objects. + * @see wikibase.datamodel.Snak + * @class jQuery.wikibase.snakview * @extends jQuery.ui.TemplatedWidget + * @since 0.3 + * @author Daniel Werner < daniel.wer...@wikimedia.de > + * @author H. Snater < mediaw...@snater.com > * - * @option {Object|wb.datamodel.Snak|null} value The snak this view should represent initially. If omitted, - * an empty view will be served, ready to take some input by the user. The value can also be - * overwritten later, by using the value() or snak() functions. - * Default: { property: null, snaktype: wb.datamodel.PropertyValueSnak.TYPE } + * @costructor * - * @option {Object|boolean} locked Key-value pairs determining which snakview elements to lock for - * being edited by the user. May also be a boolean value enabling/disabling all elements. - * Default: false (no elements to be locked) - * - * @option {boolean} autoStartEditing Whether or not view should go into edit mode by its own upon - * initialization if its initial value is empty. - * Default: true - * - * @option {wb.store.EntityStore} entityStore - * - * @option {wikibase.ValueViewBuilder} valueViewBuilder - * - * @option {dataTypes.DataTypeStore} dataTypeStore - * + * @param {Object} options + * @param {Object|wikibase.datamodel.Snak|null} [options.value] + *The `Snak` this `snakview` should represent initially. If omitted, an empty view will be + *served, ready to take some input by the user. The value may be overwritten later, by using + *the `value()` or the `snak()` function. + *Default: `{ property: null, snaktype: wikibase.datamodel.PropertyValueSnak.TYPE }` + * @param {Object|boolean} [options.locked=false] + *Key-value pairs determining which `snakview` elements to lock from being edited by the + *user. May also be a boolean value enabling/disabling all elements. If `false`, no elements + *will be locked. + * @param {boolean} [options.autoStartEditing=true] + *Whether the `snakview` should switch to edit mode automatically upon initialization if its + *initial value is empty. + * @param {wikibase.store.EntityStore} options.entityStore + *Required for dynamically gathering `Entity`/`Property` information. + * @param {wikibase.ValueViewBuilder} options.valueViewBuilder + *Required to interfacing a `snakview` "value" `Variation` to `jQuery.valueview`. + * @param {dataTypes.DataTypeStore} options.dataTypeStore + *Required to retrieve and evaluate a proper `dataTypes.DataType` object when interacting on + *a "value" `Variation`. + */ +/** * @event afterstartediting - *Triggered after having rendered edit mode. - *- {jQuery.Event} - * + * Triggered after having started the widget's edit mode. + * @param {jQuery.Event} event + */ +/** * @event stopediting - *Triggered before edit mode is stopped. - *- {jQuery.Event} - *- {boolean} dropValue - *- {wikibase.datamodel.Snak|null} newSnak - * The Snak which will be displayed after editing has stopped. Normally, this is the Snak - * representing the last state of the view during edit mode but can also be the Snak from - * before edit mode in case editing has been cancelled. - * + * Triggered when stopping the widget's edit mode. + * @param {jQuery.Event} event + * @param {boolean} dropValue + * @param {wikibase.datamodel.Snak|null} newSnak + *The `Snak` which will be displayed after editing has stopped. Normally, this is the `Snak` + *representing the last state of the `snakview` during edit mode but can also be the `Snak` + *from before edit
[MediaWiki-commits] [Gerrit] snakview: Removed NativeEventHandler - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186758 Change subject: snakview: Removed NativeEventHandler .. snakview: Removed NativeEventHandler Removed unused concept of NativeEventHandler from snakview. As the "startediting" event is not part of the common widget schema, it is removed along. Change-Id: I70d94f2868a169cab41a74edbe6875755e4b1df2 --- M lib/resources/jquery.wikibase/snakview/resources.php M lib/resources/jquery.wikibase/snakview/snakview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/statementview-snakview.js 4 files changed, 76 insertions(+), 99 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/58/186758/1 diff --git a/lib/resources/jquery.wikibase/snakview/resources.php b/lib/resources/jquery.wikibase/snakview/resources.php index eca37f3..e4cf269 100644 --- a/lib/resources/jquery.wikibase/snakview/resources.php +++ b/lib/resources/jquery.wikibase/snakview/resources.php @@ -26,7 +26,6 @@ ), 'dependencies' => array( 'jquery.event.special.eachchange', - 'jquery.NativeEventHandler', 'jquery.ui.position', 'jquery.ui.TemplatedWidget', 'jquery.wikibase.entityselector', diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index 937102e..1cd4629 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -40,10 +40,6 @@ * * @option {dataTypes.DataTypeStore} dataTypeStore * - * @event startediting - *Triggered before edit mode gets rendered. - *- {jQuery.Event} - * * @event afterstartediting *Triggered after having rendered edit mode. *- {jQuery.Event} @@ -295,61 +291,52 @@ }, /** -* Starts the edit mode where the snak can be edited. -* @since 0.3 -* -* @return {undefined} (allows chaining widget calls) +* Starts the widget's edit mode. */ - startEditing: $.NativeEventHandler( 'startEditing', { - // don't start edit mode or trigger event if in edit mode already: - initially: function( e ) { - if( this.isInEditMode() ) { - e.cancel(); + startEditing: function() { + if( this.isInEditMode() ) { + return; + } + + var self = this; + + this._initialSnak = this.snak(); + this._isInEditMode = true; + + this.element.on( 'keydown.' + this.widgetName, function( event ) { + if ( self.options.disabled ) { + return; } - }, - // start edit mode if event doesn't prevent default: - natively: function( e ) { - var self = this; - this._initialSnak = this.snak(); - this._isInEditMode = true; + var propertySelector = self._getPropertySelector(); - // attach keyboard input events - this.element.on( 'keydown.' + this.widgetName, function( event ) { - if ( self.options.disabled ) { - return; - } - - var propertySelector = self._getPropertySelector(); - - if ( event.keyCode === $.ui.keyCode.TAB && !self._variation ) { - event.stopPropagation(); - // When pressing TAB in the property input element while the value input element - // does not yet exist, we assume that the user wants to auto-complete/select the - // currently suggested property and tab into the value element. Since the API - // needs to be queried to construct the correct value input, the intended action - // needs to be cached and triggered as soon as the value input has been created. - if ( propertySelector && event.target === propertySelector.element[0] ) { - if( self._getPropertySelector().selectedEntity() ) { - self._tabToValueView = true; -
[MediaWiki-commits] [Gerrit] SnakTypeSelector: Remove 'javascript:void(0); ' href - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186755 Change subject: SnakTypeSelector: Remove 'javascript:void(0);' href .. SnakTypeSelector: Remove 'javascript:void(0);' href _58090 Change-Id: I97fed22b3666e610dd4cd2c7d8e71c3ea5459b4e --- M lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js M lib/resources/jquery.wikibase/snakview/themes/default/snakview.SnakTypeSelector.css 2 files changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/55/186755/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js index 1df67eb..c70ab8d 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js @@ -183,7 +183,7 @@ $( '' ) .addClass( classPrefix + type ) // type should only be lower case string anyhow! .data( 'snaktypeselector-menuitem-type', type ) - .append( $( '' ).attr( 'href', 'javascript:void(0);' ).text( + .append( $( '' ).text( mw.msg( 'wikibase-snakview-snaktypeselector-' + type ) ) ) ); diff --git a/lib/resources/jquery.wikibase/snakview/themes/default/snakview.SnakTypeSelector.css b/lib/resources/jquery.wikibase/snakview/themes/default/snakview.SnakTypeSelector.css index f4e8d46..648f03f 100644 --- a/lib/resources/jquery.wikibase/snakview/themes/default/snakview.SnakTypeSelector.css +++ b/lib/resources/jquery.wikibase/snakview/themes/default/snakview.SnakTypeSelector.css @@ -21,3 +21,7 @@ position: absolute; z-index: 2; /* Monobook #content has 2 */ } + +.wb-snaktypeselector-menu li a { + cursor: pointer; +} -- To view, visit https://gerrit.wikimedia.org/r/186755 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I97fed22b3666e610dd4cd2c7d8e71c3ea5459b4e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] listview: Moved value setting logic to _setOption - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186752 Change subject: listview: Moved value setting logic to _setOption .. listview: Moved value setting logic to _setOption In consistency with other widget implementations. Now, value may be set using .option( 'value', value ). Change-Id: I89d0b10db62d677813b02a552a6a68de9a5b9baa --- M lib/resources/jquery.wikibase/jquery.wikibase.listview.js 1 file changed, 22 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/186752/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js index 0820f56..871b3a7 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js @@ -150,6 +150,21 @@ if( key === 'listItemAdapter' ) { throw new Error( 'Can not change the ListItemAdapter after initialization' ); + } else if( key === 'value' ) { + // Clear listview: + this.items().each( function( i, node ) { + var $node = $( node ); + self._lia.liInstance( $node ).destroy(); + $node.remove(); + } ); + + // Add new values: + for( var i = 0; i < value.length; i++ ) { + var $newLi = $( '<' + this.option( 'listItemNodeName' ) + '/>' ) + .addClass( this.widgetName + '-item' ); + this.element.append( $newLi ); + this._lia.newListItem( $newLi, value[i] ); + } } var response = PARENT.prototype._setOption.apply( this, arguments ); @@ -181,39 +196,25 @@ }, /** -* Sets/Gets the widget's value. +* Sets the widget's value or gets the widget's current value. The widget's non-pending value +* (the value the widget was initialized with) may be retrieved via `this.option( 'value' )`. * * @param {*[]} [value] List containing a value for each list item widget. * @return {*[]|undefined} */ value: function( value ) { - var self = this; - - // Getter: if( value === undefined ) { - var values = []; + var self = this, + values = []; - this.items().each( function( i, node ) { - values.push( self._lia.liInstance( $( node ) ) ); + this.items().each( function() { + values.push( self._lia.liInstance( $( this ) ) ); } ); return values; } - // Clear listview: - this.items().each( function( i, node ) { - var $node = $( node ); - self._lia.liInstance( $node ).destroy(); - $node.remove(); - } ); - - // Add new values: - for( var i = 0; i < value.length; i++ ) { - var $newLi = $( '<' + this.option( 'listItemNodeName' ) + '/>' ) - .addClass( this.widgetName + '-item' ); - this.element.append( $newLi ); - this._lia.newListItem( $newLi, value[i] ); - } + this.option( 'value', value ); }, /** -- To view, visit https://gerrit.wikimedia.org/r/186752 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I89d0b10db62d677813b02a552a6a68de9a5b9baa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] listview: Removed NativeEventHandler - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186753 Change subject: listview: Removed NativeEventHandler .. listview: Removed NativeEventHandler NativeEventHandler logic does not have a proper use-case in listview and just adds to complexity. "additem" and "removeitem" events are used nowhere. There is no actual need for the events' existence as well as their should not be a need for them. Change-Id: Icae55bba7a420244a24be20c546f52fa46017933 --- M lib/resources/jquery.wikibase/jquery.wikibase.listview.js M lib/resources/jquery.wikibase/resources.php 2 files changed, 47 insertions(+), 85 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/53/186753/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js index 871b3a7..f5ca1e9 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js @@ -25,31 +25,11 @@ * Node name of the base node of new list items. */ /** - * @event additem - * Triggered before a list item will be added to the list. - * @param {jQuery.Event} event - * @param {*|null} value - *The value the new list item will represent. This can also be `null` in case a new, empty - *list item (not yet representing any value but ready for the user to enter a value) will - *be added. - * @param {jQuery} $li - *The DOM node on which a widget representing the new list item's value will be - *initialized. The widget will be initialized on this DOM node after the DOM node is - *appended to the list, so events can bubble during widget initialization. - */ -/** * @event itemadded * Triggered after a list item got added to the list. * @param {jQuery.Event} event * @param {*|null} value The value the new list item is representing. `null` for empty value. * @param {jQuery} $li The DOM node of the widget representing the value. - */ -/** - * @event removeitem - * Triggered before a list item will be removed from the list. - * @param {jQuery.Event} event - * @param {*|null} value The value of the list item which will be removed. `null` for empty value. - * @param {jQuery} $li The list item's DOM node which will be removed. */ /** * @event itemremoved @@ -151,19 +131,14 @@ if( key === 'listItemAdapter' ) { throw new Error( 'Can not change the ListItemAdapter after initialization' ); } else if( key === 'value' ) { - // Clear listview: this.items().each( function( i, node ) { var $node = $( node ); self._lia.liInstance( $node ).destroy(); $node.remove(); } ); - // Add new values: for( var i = 0; i < value.length; i++ ) { - var $newLi = $( '<' + this.option( 'listItemNodeName' ) + '/>' ) - .addClass( this.widgetName + '-item' ); - this.element.append( $newLi ); - this._lia.newListItem( $newLi, value[i] ); + this._addLiValue( value[i] ); } } @@ -324,73 +299,61 @@ /** * Adds one list item into the list and renders it in the view. * -* @param {*} value -* @return {jQuery} The DOM node representing the value. If default was prevented in the -* `additem` event, the node will be returned even though not appended to the list. +* @param {*} liValue One list item widget's value. */ - addItem: $.NativeEventHandler( 'additem', { - initially: function( event, value ) { - // in custom handlers, we provide the DOM node without initialized value widget because - // we want to initialize widget AFTER the node is in the DOM, so we can have events - // triggered during widget initialization bubble up the DOM! - var $newLi; - if( this._reusedItems.length > 0 ) { - $newLi = $( this._reusedItems.shift() ); + addItem: function( liValue ) { + var $li = this._addLiValue( liValue ); + this._trigger( 'itemadded', null, [liValue, $li] ); + }, + + /** +* Adds one list item into the list and renders it in the view. +* @private +* +* @param {*} liValue One list item widget's value. +* @return {jQuery} New list item's node. +*/ + _addLiValue: function( liValu
[MediaWiki-commits] [Gerrit] Renamed wb-listview to wikibase-listview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186750 Change subject: Renamed wb-listview to wikibase-listview .. Renamed wb-listview to wikibase-listview In consistency with wikibase widget naming schema. Change-Id: I68562e30297a18ee08a3999eb55e89596a83142a --- M lib/resources/jquery.wikibase/jquery.wikibase.listview.js M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js M repo/includes/View/ClaimHtmlGenerator.php M repo/includes/View/SiteLinksView.php M repo/includes/View/StatementGroupListView.php M repo/resources/templates.php 7 files changed, 12 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/50/186750/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js index f7ee5f9..e47e500 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js @@ -81,7 +81,7 @@ * @see jQuery.Widget.options */ options: { - template: 'wb-listview', + template: 'wikibase-listview', templateParams: [ '' // list items ], @@ -422,9 +422,5 @@ } } ); - -// We have to override this here because $.widget sets it no matter what's in -// the prototype -$.wikibase.listview.prototype.widgetBaseClass = 'wb-listview'; }( jQuery ) ); diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js index 0e9ffd5..fb922f1 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js @@ -78,7 +78,7 @@ _createListview: function() { var self = this; - this.$listview = this.element.find( '.wb-listview' ); + this.$listview = this.element.find( '.wikibase-listview' ); if( !this.$listview.length ) { this.$listview = $( '' ).appendTo( this.element ); diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js index 8db4589..f6ea307 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js @@ -110,7 +110,7 @@ _createListview: function() { var self = this; - this.$listview = this.element.children( '.wb-listview' ); + this.$listview = this.element.children( '.wikibase-listview' ); if( !this.$listview.length ) { this.$listview = $( '' ).appendTo( this.element ); diff --git a/repo/includes/View/ClaimHtmlGenerator.php b/repo/includes/View/ClaimHtmlGenerator.php index 05b4f9a..8db9e31 100644 --- a/repo/includes/View/ClaimHtmlGenerator.php +++ b/repo/includes/View/ClaimHtmlGenerator.php @@ -163,7 +163,7 @@ private function wrapInListview( $listviewContent ) { if( $listviewContent !== '' ) { - return $this->templateFactory->render( 'wb-listview', $listviewContent ); + return $this->templateFactory->render( 'wikibase-listview', $listviewContent ); } else { return ''; } diff --git a/repo/includes/View/SiteLinksView.php b/repo/includes/View/SiteLinksView.php index 93f2e32..e56e6bf 100644 --- a/repo/includes/View/SiteLinksView.php +++ b/repo/includes/View/SiteLinksView.php @@ -115,7 +115,7 @@ } return $this->templateFactory->render( 'wikibase-sitelinkgrouplistview', - $this->templateFactory->render( 'wb-listview', $html ) + $this->templateFactory->render( 'wikibase-listview', $html ) ); } diff --git a/repo/includes/View/StatementGroupListView.php b/repo/includes/View/StatementGroupListView.php index a139d3d..c3b0eb4 100644 --- a/repo/includes/View/StatementGroupListView.php +++ b/repo/includes/View/StatementGroupListView.php @@ -74,7 +74,7 @@ $html = $this->templateFactory->render( 'wikibase-statementgrouplistview', - $this->templateFactory->render( 'wb-listview', $claimsHtml ) + $this->templateFactory->render( 'wikibase-listview', $claimsHtml ) ); // TODO: Add link to SpecialPage that allows adding a new claim. diff --git a/repo/resources/templates.php b/repo/resources/templates.php
[MediaWiki-commits] [Gerrit] Updated listview documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186751 Change subject: Updated listview documentation .. Updated listview documentation Change-Id: Ib5daffab036e0fb59737d97de5e10966d364f01e --- M lib/resources/jquery.wikibase/jquery.wikibase.listview.js 1 file changed, 108 insertions(+), 106 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/51/186751/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js index e47e500..0820f56 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.listview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.listview.js @@ -1,84 +1,85 @@ -/** - * - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - * @author H. Snater < mediaw...@snater.com > - */ ( function( $ ) { 'use strict'; var PARENT = $.ui.TemplatedWidget; /** - * View for displaying and editing several list items, each represented by another widget. - * @since 0.4 + * View for displaying and editing list items, each represented by a single random widget. + * @class jQuery.wikibase.listview * @extends jQuery.ui.TemplatedWidget + * @since 0.4 + * @licence GNU GPL v2+ + * @author Daniel Werner < daniel.wer...@wikimedia.de > + * @author H. Snater < mediaw...@snater.com > * - * @option {*|null} value The values displayed by this view. Each value is represented by a widget - * defined in the 'listItemAdapter' option. + * @constructor * - * @option {jQuery.wikibase.listview.ListItemAdapter} listItemAdapter (required) Can not - * be changed after initialization. - * - * @option {string} [listItemNodeName] + * @param {Object} options + * @param {*[]} [options.value=null] + *The values displayed by this view. More specifically, a list of each list item widget's + *value. + * @param {jQuery.wikibase.listview.ListItemAdapter} options.listItemAdapter + *Interfaces the actual widget instances to be used by the `listview`. Cannot be changed + *after initialization. + * @param {string} [options.listItemNodeName='DIV'] * Node name of the base node of new list items. - * Default: 'DIV' - * - * @event additem: Triggered before a list item will be added to the list. - *(1) {jQuery.Event} - *(2) {*|null} The value the new list item will represent. This can also be null in case a - *new, empty list item, not yet representing any value but ready for the user to enter - *a value, will be added. - *(3) {jQuery} the DOM node on which a widget representing the new list item's value will - *be initialized. The widget will be initialized on this DOM node after the DOM node is - *appended to the list, so events can bubble during widget initialization. - * - * @event itemadded: Triggered after a list item got added to the list. - *(1) {jQuery.Event} - *(2) {*|null} The value the new list item is representing. null for empty value. - *(3) {jQuery} The DOM node with the widget, representing the value. - * - * @event removeitem: Triggered before a list item will be removed from the list. - *(1) {jQuery.Event} - *(2) {*|null} The value of the list item which will be removed. null for empty value. - *(3) {jQuery} The list item's DOM node, which will be removed. - * - * @event itemremoved: Triggered after a list got removed from the list. - *(1) {jQuery.Event} - *(2) {*|null} The value of the list item which will be removed. null for empty value. - *(3) {jQuery} The list item's DOM node, removed. - * - * @event enternewitem: Triggered when initializing the process of adding a new item to the list. - *(1) {jQuery.Event} - *(2) {jQuery} The DOM node pending to be added permanently to the list. - * - * @event afteritemmove: Triggered when an item node is moved within the list. - *(1) {jQuery.Event} - *(2) {number} The item node's new index. - *(3) {number} Number of items in the list. - * + */ +/** + * @event additem + * Triggered before a list item will be added to the list. + * @param {jQuery.Event} event + * @param {*|null} value + *The value the new list item will represent. This can also be `null` in case a new, empty + *list item (not yet representing any value but ready for the user to enter a value) will + *be added. + * @param {jQuery} $li + *The DOM node on which a widget representing the new list item's value will be + *initialized. The widget will be initialized on this DOM node after the DOM node is + *appended to the list, so events can bubble during widget initialization. + */ +/** + * @event itemadded + * Triggered after a
[MediaWiki-commits] [Gerrit] Updated listview.ListItemAdapter documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186754 Change subject: Updated listview.ListItemAdapter documentation .. Updated listview.ListItemAdapter documentation Change-Id: Iac890a3e0f5fee4e120fa76dbe71804b29780a98 --- M lib/resources/jquery.wikibase/jquery.wikibase.listview.ListItemAdapter.js 1 file changed, 69 insertions(+), 69 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/54/186754/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.listview.ListItemAdapter.js b/lib/resources/jquery.wikibase/jquery.wikibase.listview.ListItemAdapter.js index 7489e8e..fae2f94 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.listview.ListItemAdapter.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.listview.ListItemAdapter.js @@ -1,93 +1,95 @@ -/** - * - * @licence GNU GPL v2+ - * @author Daniel Werner < daniel.wer...@wikimedia.de > - */ ( function( $ ) { 'use strict'; /** -* Required as information about the kind of widget used for items in a listview widget. -* -* ARCHITECTURAL NOTE: This is basically a strategy giving the listview information about what -* kinds of items it deals with. An alternative attempt would be for the listview to use -* composition where the list would own one object for each of its list items, giving the list -* information about that item. This attempt would allow to handle values of different kinds -* in the same listview widget but would require an additional object per list item while our -* current attempt only requires one strategy object which can be shared by all lists dealing -* with that value type. Allowing the listview to deal with different kinds of values but -* sticking with this pattern might also be possible by providing the listview with a function -* to determine the kind of a value and then choosing the right strategy to deal with the value. -* -* @param {Object} options See each particular options documentation. Each option marked as -*'(required)' has to be given as a field within the object. -* -* @option listItemWidget {Function} (required) The constructor of the jQuery widget which -* should represent items in a list using this ListItemAdapter definition. -* -* @option newItemOptionsFn {Function} (required) A callback which will be called when the -* related list is instantiating a new list item. The callback has to return an Object -* which will then be used as options object for a new widget (specified in -* 'listItemWidget' option) representing the new list item's value. The new new list -* item's value is given as the callback's first parameter, if an empty list item should -* be created, the value will be null. The callback's context is the ListItemAdapter -* instance. -* +* Interface between a `jQuery.wikibase.listview` instance and the widget the `listview` is +* supposed to use for its list items. +* ARCHITECTURAL NOTE: This, basically, is a strategy providing information to the `listview` +* about the kind of items it deals with. An alternative would be to use composition with the +* `listview` managing a dedicated object for each list item. While that would allow handling +* values of different kinds in the same `listview` widget, it would require an additional +* object per list item. By using a single `ListItemAdapter`, only one object is required as it +* can be applied to all `listview` items. Enabling the `listview` to deal with different kinds +* of values but sticking with this pattern might be possible by providing a function the +* `listview` determining the kind of a value and choosing the right strategy to deal with the +* value accordingly. +* @see jQuery.wikibase.listview +* @class jQuery.wikibase.listview.ListItemAdapter * @since 0.4 +* @licence GNU GPL v2+ +* @author Daniel Werner < daniel.wer...@wikimedia.de > +* +* @constructor +* +* @param {Object} options +* @param {Function} options.listItemWidget +*The constructor of the jQuery widget which should represent items in a `listview`. +*The widget is required to feature a `value` method that allows setting and retrieving +*the widget's value. +* @param {Function} options.newItemOptionsFn +*A function called when the related `listview` is instantiating a new list item. The +*function has to return an `Object` which w
[MediaWiki-commits] [Gerrit] statementgrouplistview: Added value() function - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186337 Change subject: statementgrouplistview: Added value() function .. statementgrouplistview: Added value() function Change-Id: Ib72249bce43fc297870edc8101d40d91a87ad268 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementgrouplistview.tests.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementlistview.tests.js 4 files changed, 160 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/37/186337/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js index cd8c651..b05c89e 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js @@ -116,13 +116,6 @@ this.$listview = $( '' ).appendTo( this.element ); } - var propertyIds = this.options.value.getKeys(), - value = []; - - for( var i = 0; i < propertyIds.length; i++ ) { - value.push( this.options.value.getItemByKey( propertyIds[i] ) ); - } - this.$listview.listview( { listItemAdapter: new $.wikibase.listview.ListItemAdapter( { listItemWidget: $.wikibase.statementgroupview, @@ -137,7 +130,19 @@ }; } } ), - value: value + value: self._statementGroupSetToStatementGroups( this.options.value ) + } ); + }, + + /** +* @private +* +* @param {wikibase.datamodel.StatementGroup} statementGroupSet +* @return {wikibase.datamodel.StatementList[]} +*/ + _statementGroupSetToStatementGroups: function( statementGroupSet ) { + return $.map( statementGroupSet.getKeys(), function( propertyId ) { + return statementGroupSet.getItemByKey( propertyId ); } ); }, @@ -218,10 +223,40 @@ }, /** +* Sets the widget's value or retrieves the widget's current value (including any pending +* changes). The value the widget was initialized with may be retrieve using +* `this.option( 'value' )`. +* +* @param {wikibase.datamodel.StatementGroupSet} [statementGroupSet] +* @return {wikibase.datamodel.StatementGroupSet|undefined} +*/ + value: function( statementGroupSet ) { + if( statementGroupSet === undefined ) { + return new wb.datamodel.StatementGroupSet( + $.map( this.$listview.data( 'listview' ).value(), function( statementGroup ) { + return statementGroup.value(); + } ) + ); + } + this.option( 'value', statementGroupSet ); + }, + + /** * @inheritdoc * @protected */ _setOption: function( key, value ) { + if( key === 'value' && value !== undefined ) { + if( !( value instanceof wb.datamodel.StatementGroupSet ) ) { + throw new Error( + 'value needs to be an instance of wb.datamodel.StatementGroupSet' + ); + } + this.$listview.data( 'listview' ).value( + this._statementGroupSetToStatementGroups( value ) + ); + } + var response = PARENT.prototype._setOption.apply( this, arguments ); if( key === 'disabled' ) { diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js index 9cdeccc..f8ce6c6 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js @@ -236,6 +236,15 @@ }, /** +* Returns whether the widget currently features any `statementview` widgets. +* +* @return {boolean} +*/ + isEmpty: function() { + return !this.listview().items().length; + }, + + /** * Adds a new, pending `statementview` to the `statementlistview`. * @see jQuery.wikibase.listview.enterNewItem *
[MediaWiki-commits] [Gerrit] statementview: Fixed initializing qualifiers - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186238 Change subject: statementview: Fixed initializing qualifiers .. statementview: Fixed initializing qualifiers Change-Id: I36625b155fb5889144c0a2663e418b5feff59c5e --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/38/186238/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index bd61655..9a56f2a 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -519,7 +519,7 @@ // TODO: Allow adding qualifiers when adding a new statement. if( this.options.value && ( this.isInEditMode() || this._initialQualifiers.length ) ) { - this._createQualifiersListview(); + this._createQualifiersListview( this.options.value.getClaim().getQualifiers() ); } this._createReferences( this.options.value ); @@ -686,7 +686,7 @@ PARENT.prototype.startEditing.call( self ).done( function() { self._rankSelector.startEditing(); - if( this._qualifiers ) { + if( self._qualifiers ) { var snaklistviews = self._qualifiers.value(); if( snaklistviews.length ) { for( var i = 0; i < snaklistviews.length; i++ ) { -- To view, visit https://gerrit.wikimedia.org/r/186238 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I36625b155fb5889144c0a2663e418b5feff59c5e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implemented statementgroupview widget - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/186228 Change subject: Implemented statementgroupview widget .. Implemented statementgroupview widget statementgroupview was yet missing in the hierarchy: statementgrouplistview > statmentgroupview > statementlistview > statementview Change-Id: Id982a39416fb1c9d7f7361f3154216eca6ec12c7 --- M lib/resources/Resources.php M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js A lib/resources/jquery.wikibase/jquery.wikibase.statementgroupview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/resources/jquery.wikibase/resources.php A lib/resources/jquery.wikibase/themes/default/jquery.wikibase.statementgroupview.css R lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementgrouplistview-statementgroupview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js M lib/resources/jquery.wikibase/toolbar/controller/resources.php M lib/resources/wikibase.css M lib/tests/qunit/jquery.wikibase/jquery.wikibase.itemview.tests.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.propertyview.tests.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementgrouplistview.tests.js A lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementgroupview.tests.js A lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementlistview.tests.js M lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementview.tests.js M lib/tests/qunit/jquery.wikibase/resources.php M repo/includes/View/StatementGroupListView.php M repo/resources/Resources.php M repo/resources/templates.php M repo/resources/wikibase.ui.entityViewInit.js 21 files changed, 905 insertions(+), 335 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/28/186228/1 diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php index 2957835..2d245f7 100644 --- a/lib/resources/Resources.php +++ b/lib/resources/Resources.php @@ -42,6 +42,7 @@ 'jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css', 'jquery.wikibase/themes/default/jquery.wikibase.sitelinklistview.css', 'jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css', + 'jquery.wikibase/themes/default/jquery.wikibase.statementgroupview.css', ) ), diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js index b969803..7a8cdc3 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js @@ -5,10 +5,10 @@ /** * View for displaying `wikibase.datamodel.Statement` objects grouped by their main `Snak`'s - * `Property` id by managing a list of `jQuery.wikibase.statementlistview` widgets. + * `Property` id by managing a list of `jQuery.wikibase.statementgroupview` widgets. * @see wikibase.datamodel.StatementGroup * @see wikibase.datamodel.StatementGroupSet - * @uses jQuery.wikibase.statementlistview + * @uses jQuery.wikibase.statementgroupview * @uses jQuery.wikibase.listview * @uses jQuery.wikibase.listview.ListItemAdapter * @since 0.5 @@ -16,12 +16,12 @@ * @licence GNU GPL v2+ * @author H. Snater < mediaw...@snater.com > * - * @option {wikibase.datamodel.ClaimGroupSet|{wikibase.datamodel.StatementGroupSet} [value] + * @option {wikibase.datamodel.StatementGroupSet} value * The `Statements` to be displayed by this view. If null, the view will display only an add * button to add new `Statements`. * Default: null * - * @option {string} entityType Type of the entity that the statementgrouplistview referes to. + * @option {string} entityType Type of the entity that the statementgrouplistview refers to. * Default: wb.datamodel.Item.type * * @option {wikibase.store.EntityStore} entityStore @@ -37,19 +37,21 @@ options: { template: 'wikibase-statementgrouplistview', templateParams: [ - '', // statementlistview widgets - '' // toolbar + '' // listview ], - templateShortCuts: { - $listview: '.wikibase-statementgrouplistview-listview' - }, + templateShortCuts: {}, value: null, - entityType: wb.datamodel.Item.type, + entityType: wb.datamodel.Item.TYPE, dataTypeStore: null, entityStore: null, valueViewBuilder: null, entityChangersFactory: null
[MediaWiki-commits] [Gerrit] sitelinklistview: Not adding pending empty lines to counter - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185979 Change subject: sitelinklistview: Not adding pending empty lines to counter .. sitelinklistview: Not adding pending empty lines to counter _87195 Change-Id: I84d8ad4a07839b5525b8b6495656ab87992b7496 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js 1 file changed, 7 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/79/185979/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js index 47b4f0c..927152a 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js @@ -143,6 +143,7 @@ event.stopPropagation(); if( self.options.autoInput ) { self._updateAutoInput(); + self._refreshCounter(); } self._trigger( 'change' ); } ) @@ -283,8 +284,12 @@ * @return {jQuery} */ _getFormattedCounterText: function() { - var $items = this.$listview.data( 'listview' ).items(), - $pendingItems = $items.filter( '.wb-new' ); + var listview = this.$listview.data( 'listview' ), + lia = listview.listItemAdapter(), + $items = listview.items(), + $pendingItems = $items.filter( '.wb-new' ).filter( function() { + return !lia.liInstance( $( this ) ).isEmpty(); + } ); var $counterMsg = wb.utilities.ui.buildPendingCounter( $items.length - $pendingItems.length, -- To view, visit https://gerrit.wikimedia.org/r/185979 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I84d8ad4a07839b5525b8b6495656ab87992b7496 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] siteselector: Degrade on pressing ESC - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185976 Change subject: siteselector: Degrade on pressing ESC .. siteselector: Degrade on pressing ESC - 40360 Change-Id: I73c01caaba521af8cc2a1a1c904196f676766110 --- M lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js 1 file changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/76/185976/1 diff --git a/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js b/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js index e5033c1..514d57f 100644 --- a/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js +++ b/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js @@ -52,6 +52,26 @@ .one( 'selected', function( event, item ) { self.element.val( item.getValue() ); } ); + } else if( event.keyCode === $.ui.keyCode.ESCAPE ) { + var degrade = true, + firstItem = self.options.menu.option( 'items' )[0]; + + if( firstItem ) { + var site = firstItem.getSite(), + label = self._createItemLabel( site, '' ), + value = self._createItemValue( site ); + + if( self._term === label || self._term === value ) { + degrade = false; + } + } + + if( degrade ) { + self.options.menu.deactivate(); + self.element.val( self._term ); + self._selectedSite = null; + self._trigger( 'selected', null, [null] ); + } } } ) .on( 'eachchange.' + this.widgetName, function( event, previousValue ) { @@ -130,6 +150,9 @@ } else if( self.element.val() !== '' ) { self._selectFirstSite(); } + } ) + .on( 'keydown.siteselector', function( event ) { + console.log( event.keyCode ); } ); this.options.menu.element -- To view, visit https://gerrit.wikimedia.org/r/185976 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I73c01caaba521af8cc2a1a1c904196f676766110 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Removed pointless 'wikibase-statementview' wrapper - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185824 Change subject: Removed pointless 'wikibase-statementview' wrapper .. Removed pointless 'wikibase-statementview' wrapper Change-Id: I737b2f63892b22a2d86419aac9c01b3b8f58e92b --- M lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/resources/wikibase.css M repo/includes/View/StatementGroupListView.php 4 files changed, 12 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/24/185824/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js index ef77de9..d608edf 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js @@ -75,7 +75,7 @@ var listview = this.listview(), lia = listview.listItemAdapter(), - startEditingEvent = lia.prefixedEvent( 'startediting.' + this.widgetName ), + afterStartEditingEvent = lia.prefixedEvent( 'afterstartediting.' + this.widgetName ), afterStopEditingEvent = lia.prefixedEvent( 'afterstopediting.' + this.widgetName ), afterRemoveEvent = lia.prefixedEvent( 'afterremove.' + this.widgetName ), errorEvent = lia.prefixedEvent( 'toggleerror.' + this.widgetName ); @@ -88,7 +88,7 @@ self._toggleGroupTitleClass( $( event.target ), 'wb-error' ); self._removeGroupTitleClass( $( event.target ), 'wb-edit' ); } ) - .on( startEditingEvent, function( event ) { + .on( afterStartEditingEvent, function( event ) { self._addGroupTitleClass( $( event.target ), 'wb-edit' ); } ) .on( afterRemoveEvent, function( event ) { diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js index 7e8a87f..e0327a7 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js @@ -38,8 +38,8 @@ *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` *object when interacting on a "value" `Variation`. /** - * @event startediting - * Triggered when edit mode is started for one of the `statementview` widgets managed by the + * @event afterstartediting + * Triggered when edit mode has been started for one of the `statementview` widgets managed by the * `statementlistview`. * @param {jQuery.Event} event */ @@ -118,15 +118,16 @@ var self = this, lia = this.listview().listItemAdapter(), - startEditingEvent = lia.prefixedEvent( 'startediting.' + this.widgetName ), + afterStartEditingEvent + = lia.prefixedEvent( 'afterstartediting.' + this.widgetName ), afterStopEditingEvent = lia.prefixedEvent( 'afterstopediting.' + this.widgetName ), toggleErrorEvent = lia.prefixedEvent( 'toggleerror.' + this.widgetName ); this.element - .on( startEditingEvent, function( event ) { + .on( afterStartEditingEvent, function( event ) { // Forward "startediting" event for higher components (e.g. statementgrouplistview) to // recognize that edit mode has been started. - self._trigger( 'startediting' ); + self._trigger( 'afterstartediting' ); } ) .on( afterStopEditingEvent, function( event, dropValue ) { var $statementview = $( event.target ), diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css index 2c01f45..ab4ccc8 100644 --- a/lib/resources/wikibase.css +++ b/lib/resources/wikibase.css @@ -205,7 +205,7 @@ } /* Section of claims referring to one property */ -.wikibase-statementlistview-listview .wikibase-statementlistview { +.wikibase-statementgrouplistview .wikibase-statementlistview { position: relative; background-color: #FFF; float: left; @@ -307,12 +307,12 @@ display: none; } -.wikibase-statementlistview-listview .wikibase-statementgrouplistview-groupname.wb-edit, +.wikibase-statementgrouplistview .wikibase-statementgrouplistview-groupname.wb-edit, .wikibase-statementlistview-listview .wb-edit .wb-snak-property-container { background-color: #C0
[MediaWiki-commits] [Gerrit] Renamed ClaimsView to StatementGroupListView - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185822 Change subject: Renamed ClaimsView to StatementGroupListView .. Renamed ClaimsView to StatementGroupListView Synchronizing with front-end terminology. Change-Id: Ie1624e62149bea54a139dc9cebe7c61232fec838 --- M repo/includes/View/EntityView.php M repo/includes/View/EntityViewFactory.php M repo/includes/View/ItemView.php M repo/includes/View/PropertyView.php R repo/includes/View/StatementGroupListView.php M repo/tests/phpunit/includes/View/ClaimsViewTest.php M repo/tests/phpunit/includes/View/ItemViewTest.php M repo/tests/phpunit/includes/View/PropertyViewTest.php 8 files changed, 42 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/22/185822/1 diff --git a/repo/includes/View/EntityView.php b/repo/includes/View/EntityView.php index 6d8b1cb..5ecc29c 100644 --- a/repo/includes/View/EntityView.php +++ b/repo/includes/View/EntityView.php @@ -37,11 +37,6 @@ private $fingerprintView; /** -* @var ClaimsView -*/ - protected $claimsView; - - /** * @var Language */ protected $language; @@ -59,19 +54,16 @@ /** * @param TemplateFactory $templateFactory * @param FingerprintView $fingerprintView -* @param ClaimsView $claimsView * @param Language $language * @param bool $editable */ public function __construct( TemplateFactory $templateFactory, FingerprintView $fingerprintView, - ClaimsView $claimsView, Language $language, - $editable = true + $editable = true ) { $this->fingerprintView = $fingerprintView; - $this->claimsView = $claimsView; $this->language = $language; $this->editable = $editable; diff --git a/repo/includes/View/EntityViewFactory.php b/repo/includes/View/EntityViewFactory.php index 5fe7d01..b69fdbc 100644 --- a/repo/includes/View/EntityViewFactory.php +++ b/repo/includes/View/EntityViewFactory.php @@ -143,7 +143,11 @@ $editable = true ) { $fingerprintView = $this->newFingerprintView( $languageCode ); - $claimsView = $this->newClaimsView( $languageCode, $fallbackChain, $labelLookup ); + $statementGroupListView = $this->newStatementGroupListView( + $languageCode, + $fallbackChain, + $labelLookup + ); // @fixme all that seems needed in EntityView is language code and dir. $language = Language::factory( $languageCode ); @@ -164,7 +168,7 @@ return new ItemView( $this->templateFactory, $fingerprintView, - $claimsView, + $statementGroupListView, $language, $siteLinksView, $this->siteLinkGroups, @@ -174,7 +178,7 @@ return new PropertyView( $this->templateFactory, $fingerprintView, - $claimsView, + $statementGroupListView, $this->dataTypeFactory, $language, $editable @@ -189,9 +193,9 @@ * @param LanguageFallbackChain|null $fallbackChain * @param LabelLookup|null $labelLookup * -* @return ClaimsView +* @return StatementGroupListView */ - private function newClaimsView( + private function newStatementGroupListView( $languageCode, LanguageFallbackChain $fallbackChain = null, LabelLookup $labelLookup = null @@ -209,7 +213,7 @@ $snakHtmlGenerator ); - return new ClaimsView( + return new StatementGroupListView( $this->templateFactory, $propertyIdFormatter, $this->sectionEditLinkGenerator, diff --git a/repo/includes/View/ItemView.php b/repo/includes/View/ItemView.php index e97569a..bf47cc2 100644 --- a/repo/includes/View/ItemView.php +++ b/repo/includes/View/ItemView.php @@ -21,6 +21,11 @@ class ItemView extends EntityView { /** +* @var StatementGroupListView +*/ + private $statementGroupListView; + + /** *
[MediaWiki-commits] [Gerrit] Renamed claimgrouplistview to statementgrouplistview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185818 Change subject: Renamed claimgrouplistview to statementgrouplistview .. Renamed claimgrouplistview to statementgrouplistview As the concept of Claim is to be removed, the term has become obsolete. Change-Id: Ib38551dc2d74c1ae7f2550c37748618b798607a7 --- M lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js R lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/resources/jquery.wikibase/resources.php D lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/claimgrouplistview-statementlistview.js A lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementgrouplistview-statementlistview.js M lib/resources/jquery.wikibase/toolbar/controller/resources.php M lib/resources/wikibase.css D lib/tests/qunit/jquery.wikibase/jquery.wikibase.claimgrouplistview.tests.js A lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementgrouplistview.tests.js M lib/tests/qunit/jquery.wikibase/resources.php M repo/includes/View/ClaimsView.php M repo/resources/Resources.php M repo/resources/templates.php M repo/resources/wikibase.ui.entityViewInit.js 17 files changed, 276 insertions(+), 268 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/18/185818/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js index c9abc87..f738077 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js @@ -121,8 +121,11 @@ for( var i = 0; i < $visibleClaims.length; i++ ) { var $visibleClaim = $visibleClaims.eq( i ), $claimGroup = $visibleClaim.closest( '.wikibase-statementlistview' ), - $claimNameSection = $claimGroup.children( '.wb-claimgrouplistview-groupname' ), - $claimGroupLabel = $claimNameSection.children( '.wb-claim-name' ); + $claimNameSection + = $claimGroup.children( '.wikibase-statementgrouplistview-groupname' ), + $claimGroupLabel = $claimNameSection.children( + '.wikibase-statementgrouplistview-groupname-name' + ); if( !$claimNameSection.length ) { // No claim name present (claim likely is pending). diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index 8ac6f12..51cb558 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -8,7 +8,7 @@ * @see wikibase.datamodel.Item * @class jQuery.wikibase.itemview * @extends jQuery.wikibase.entityview - * @uses jQuery.wikibase.claimgrouplistview + * @uses jQuery.wikibase.statementgrouplistview * @uses jQuery.wikibase.claimgrouplabelscroll * @uses jQuery.wikibase.sitelinkgrouplistview * @since 0.5 @@ -43,13 +43,13 @@ * @protected */ _initStatements: function() { - this.$statements = $( '.wb-claimgrouplistview', this.element ).first(); + this.$statements = $( '.wikibase-statementgrouplistview', this.element ).first(); if( this.$statements.length === 0 ) { this.$statements = $( '' ).appendTo( this.element ); } this.$statements - .claimgrouplistview( { + .statementgrouplistview( { value: this.options.value.getStatements(), dataTypeStore: this.option( 'dataTypeStore' ), entityType: this.options.value.getType(), @@ -60,7 +60,7 @@ .claimgrouplabelscroll(); // This is here to be sure there is never a duplicate id: - $( '.wb-claimgrouplistview' ) + $( '.wikibase-statementgrouplistview' ) .prev( '.wb-section-heading' ) .first() .attr( 'id', 'claims' ); @@ -129,7 +129,7 @@ _setState: function( state ) { PARENT.prototype._setState.call( this, state ); - this.$statements.data( 'claimgrouplistview' )[stat
[MediaWiki-commits] [Gerrit] Renamed claimlistview to statementlistview - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185817 Change subject: Renamed claimlistview to statementlistview .. Renamed claimlistview to statementlistview As the concept of Claim is to be removed, the term has become obsolete. Change-Id: Ie1edabffa7df8793e997ed831c0b97087c431ee0 --- M lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js M lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js R lib/resources/jquery.wikibase/jquery.wikibase.statementlistview.js M lib/resources/jquery.wikibase/resources.php R lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/claimgrouplistview-statementlistview.js D lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/claimlistview-statementview.js A lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/statementlistview-statementview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js M lib/resources/jquery.wikibase/toolbar/controller/resources.php M lib/resources/wikibase.css M lib/tests/qunit/jquery.wikibase/jquery.wikibase.claimgrouplistview.tests.js M repo/includes/View/ClaimsView.php M repo/resources/Resources.php M repo/resources/templates.php M repo/resources/wikibase.ui.entityViewInit.js 17 files changed, 197 insertions(+), 195 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/17/185817/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js index 4430f6e..c9abc87 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js @@ -120,7 +120,7 @@ for( var i = 0; i < $visibleClaims.length; i++ ) { var $visibleClaim = $visibleClaims.eq( i ), - $claimGroup = $visibleClaim.closest( '.wb-claimlistview' ), + $claimGroup = $visibleClaim.closest( '.wikibase-statementlistview' ), $claimNameSection = $claimGroup.children( '.wb-claimgrouplistview-groupname' ), $claimGroupLabel = $claimNameSection.children( '.wb-claim-name' ); @@ -176,7 +176,7 @@ * @return {jQuery} */ function findFirstVisibleMainSnakElementsWithinClaimList( $searchRange ) { - var $claimGroups = $searchRange.find( '.wb-claimlistview' ), + var $claimGroups = $searchRange.find( '.wikibase-statementlistview' ), $visibleClaimGroups = $(); // TODO: Optimize! E.g.: diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js index d0953cc..4e29f86 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js @@ -5,10 +5,10 @@ /** * View for displaying `wikibase.datamodel.Statement` objects grouped by their main `Snak`'s - * `Property` id by managing a list of `jQuery.wikibase.claimlistview` widgets. + * `Property` id by managing a list of `jQuery.wikibase.statementlistview` widgets. * @see wikibase.datamodel.StatementGroup * @see wikibase.datamodel.StatementGroupSet - * @uses jQuery.wikibase.claimlistview + * @uses jQuery.wikibase.statementlistview * @uses jQuery.wikibase.listview * @uses jQuery.wikibase.listview.ListItemAdapter * @since 0.5 @@ -37,7 +37,7 @@ options: { template: 'wb-claimgrouplistview', templateParams: [ - '', // claimlistview widgets + '', // statementlistview widgets '' // toolbar ], templateShortCuts: { @@ -92,13 +92,13 @@ self._addGroupTitleClass( $( event.target ), 'wb-edit' ); } ) .on( afterRemoveEvent, function( event ) { - // Check whether the whole claimlistview may be removed from the claimgrouplistview if - // the last statementview has been removed from the claimlistview. - var $claimlistview = $( event.target ), - claimlistview = lia.liInstance( $claimlistview ); + // Check whether the whole statementlistview may be removed from the claimgrouplistview + // if the last statementview has been removed from the statementlist
[MediaWiki-commits] [Gerrit] Renamed claimgrouplabelscroll to statementgrouplabelscroll - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185819 Change subject: Renamed claimgrouplabelscroll to statementgrouplabelscroll .. Renamed claimgrouplabelscroll to statementgrouplabelscroll Change-Id: I2e8d35365ec18dfa2b7b7eeea95942475ef00632 --- M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js R lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js M lib/resources/jquery.wikibase/resources.php D lib/tests/qunit/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.tests.js A lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.tests.js M lib/tests/qunit/jquery.wikibase/resources.php 7 files changed, 126 insertions(+), 121 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/19/185819/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index 51cb558..58dab58 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -9,7 +9,7 @@ * @class jQuery.wikibase.itemview * @extends jQuery.wikibase.entityview * @uses jQuery.wikibase.statementgrouplistview - * @uses jQuery.wikibase.claimgrouplabelscroll + * @uses jQuery.wikibase.statementgrouplabelscroll * @uses jQuery.wikibase.sitelinkgrouplistview * @since 0.5 * @licence GNU GPL v2+ @@ -57,7 +57,7 @@ valueViewBuilder: this.options.valueViewBuilder, entityChangersFactory: this.options.entityChangersFactory } ) - .claimgrouplabelscroll(); + .statementgrouplabelscroll(); // This is here to be sure there is never a duplicate id: $( '.wikibase-statementgrouplistview' ) diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js index 864b8a9..3b548c5 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js @@ -9,7 +9,7 @@ * @class jQuery.wikibase.propertyview * @extends jQuery.wikibase.entityview * @uses jQuery.wikibase.statementgrouplistview - * @uses jQuery.wikibase.claimgrouplabelscroll + * @uses jQuery.wikibase.statementgrouplabelscroll * @since 0.5 * @licence GNU GPL v2+ * @author H. Snater < mediaw...@snater.com > @@ -82,7 +82,7 @@ valueViewBuilder: this.options.valueViewBuilder, entityChangersFactory: this.options.entityChangersFactory } ) - .claimgrouplabelscroll(); + .statementgrouplabelscroll(); // This is here to be sure there is never a duplicate id: $( '.wikibase-statementgrouplistview' ) diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js similarity index 75% rename from lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js rename to lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js index f738077..7f799cc 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplabelscroll.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementgrouplabelscroll.js @@ -5,15 +5,15 @@ ( function( $ ) { 'use strict'; - var WIDGET_NAME = 'claimgrouplabelscroll'; + var WIDGET_NAME = 'statementgrouplabelscroll'; /** -* For keeping track of currently active claimgrouplabelscroll widgets which need updates on +* For keeping track of currently active statementgrouplabelscroll widgets which need updates on * certain browser window events. * * NOTE: In this performance critical case this makes more sense than jQuery's widget selector. * -* @type {jQuery.wikibase.claimgrouplabelscroll[]} +* @type {jQuery.wikibase.statementgrouplabelscroll[]} */ var activeInstances = []; @@ -44,7 +44,7 @@ } /** -* Name of the animation queue used for animations moving the claim group labels around. +* Name of the animation queue used for animations moving the `Statement` group labels around. * @type {string} */ var ANIMATION_QUEUE = 'wikibase-' + WIDGET_NAME; @@ -56,18 +56,18 @@ var expensiveChecks = 0; /** -* Widget which will reposition labels of Claim groups while scrolling through the page. This -* ensures that the labels are always displayed on the same line with the first Main Snak +* Widget which will reposition labels of `Statemen
[MediaWiki-commits] [Gerrit] statementview toolbar definition: Updated naming - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185410 Change subject: statementview toolbar definition: Updated naming .. statementview toolbar definition: Updated naming Change-Id: Ib79dfb1c92020b7183d122325b48e00b8acd012e --- M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js 1 file changed, 22 insertions(+), 25 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/10/185410/1 diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js index 84dbd16..6c67a5b 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js @@ -13,40 +13,39 @@ + '-' + $.wikibase.statementview.prototype.widgetName, events: { 'statementviewcreate': function( event, toolbarcontroller ) { - var viewType = event.type.replace( /create$/, '' ), - $view = $( event.target ), - view = $view.data( viewType ), + var $statementview = $( event.target ), + statementview = $statementview.data( 'statementview' ), options = { - interactionWidget: view + interactionWidget: statementview }, - $container = $view.children( '.wikibase-toolbar-container' ); + $container = $statementview.children( '.wikibase-toolbar-container' ); if( !$container.length ) { - $container = $( '' ).appendTo( $view ); + $container = $( '' ).appendTo( $statementview ); } options.$container = $container; - if( !!view.value() ) { + if( !!statementview.value() ) { options.onRemove = function() { - var $claimlistview = $view.closest( ':wikibase-claimlistview' ), + var $claimlistview = $statementview.closest( ':wikibase-claimlistview' ), claimlistview = $claimlistview.data( 'claimlistview' ); if( claimlistview ) { - claimlistview.remove( view ); + claimlistview.remove( statementview ); } }; } - $view.edittoolbar( options ); + $statementview.edittoolbar( options ); - $view.on( 'keydown.edittoolbar', function( event ) { - if( view.option( 'disabled' ) ) { + $statementview.on( 'keydown.edittoolbar', function( event ) { + if( statementview.option( 'disabled' ) ) { return; } if( event.keyCode === $.ui.keyCode.ESCAPE ) { - view.stopEditing( true ); + statementview.stopEditing( true ); } else if( event.keyCode === $.ui.keyCode.ENTER ) { - view.stopEditing( false ); + statementview.stopEditing( false ); } } ); }, @@ -56,10 +55,9 @@ $statementview.off( '.edittoolbar' ); }, 'statementviewchange': function( event ) { - var $target = $( event.target ), - viewType = event.type.replace( /change$/, '' ), - view = $target.data( viewType ), - edittoolbar = $target.data( 'edittoolbar' ), + var $statementview = $( event.target ), + statementview = $statementview.data( 'statementview' ), + edittoolbar = $statementview.data( 'edittoolbar' ), btnSave = edittoolbar.getButton( 'save' ); /** @@ -88,19 +86,18 @@ return enable && !( areInitialQualifiers && statem
[MediaWiki-commits] [Gerrit] statementview: Not triggering "change" event - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185411 Change subject: statementview: Not triggering "change" event .. statementview: Not triggering "change" event Not triggering "change" event when starting the snakview's edit mode as there is no actual change being performed; 86895 Change-Id: Ie2736cea14c5f3b410141de0de64a2a7c64548b7 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js 2 files changed, 5 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/11/185411/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index 08c0b82..112a1e8 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -257,16 +257,10 @@ var self = this; this.$mainSnak - .on( - [ - 'snakviewchange.' + this.widgetName, - 'snakviewafterstartediting.' + this.widgetName - ].join( ' ' ), - function( event, status ) { - event.stopPropagation(); - self._trigger( 'change' ); - } - ) + .on( 'snakviewchange.' + this.widgetName, function( event, status ) { + event.stopPropagation(); + self._trigger( 'change' ); + } ) .on( 'snakviewstopediting.' + this.widgetName, function( event ) { event.stopPropagation(); } ); diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js index 6c67a5b..3cf86e5 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/statementview.js @@ -54,7 +54,7 @@ toolbarController.destroyToolbar( $statementview.data( 'edittoolbar' ) ); $statementview.off( '.edittoolbar' ); }, - 'statementviewchange': function( event ) { + 'statementviewchange statementviewafterstartediting': function( event ) { var $statementview = $( event.target ), statementview = $statementview.data( 'statementview' ), edittoolbar = $statementview.data( 'edittoolbar' ), -- To view, visit https://gerrit.wikimedia.org/r/185411 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2736cea14c5f3b410141de0de64a2a7c64548b7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Updated claimgrouplistview code documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185168 Change subject: Updated claimgrouplistview code documentation .. Updated claimgrouplistview code documentation Change-Id: If9590560c44db101301da83f4120a053461c4098 --- M lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js 1 file changed, 43 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/68/185168/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js index 2667649..d0953cc 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimgrouplistview.js @@ -1,16 +1,20 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < mediaw...@snater.com > - */ ( function( wb, $ ) { 'use strict'; var PARENT = $.ui.TemplatedWidget; /** - * View for displaying claim groups (claimlistviews). + * View for displaying `wikibase.datamodel.Statement` objects grouped by their main `Snak`'s + * `Property` id by managing a list of `jQuery.wikibase.claimlistview` widgets. + * @see wikibase.datamodel.StatementGroup + * @see wikibase.datamodel.StatementGroupSet + * @uses jQuery.wikibase.claimlistview + * @uses jQuery.wikibase.listview + * @uses jQuery.wikibase.listview.ListItemAdapter * @since 0.5 * @extends jQuery.ui.TemplatedWidget + * @licence GNU GPL v2+ + * @author H. Snater < mediaw...@snater.com > * * @option {wikibase.datamodel.ClaimGroupSet|{wikibase.datamodel.StatementGroupSet} [value] * The claims to be displayed by this view. If null, the view will display only an add @@ -48,19 +52,24 @@ }, /** -* @see jQuery.Widget._create +* @inheritdoc +* @protected * -* @throws {Error} if any required option is not specified. +* @throws {Error} if a required option is not specified properly. */ _create: function() { - if( !this.options.entityStore || !this.options.valueViewBuilder || !this.options.entityChangersFactory ) { - throw new Error( 'Required option(s) missing' ); + if( + !this.options.entityStore + || !this.options.valueViewBuilder + || !this.options.entityChangersFactory + ) { + throw new Error( 'Required option not specified properly' ); } PARENT.prototype._create.call( this ); var self = this, - claims = this.option( 'value' ); + statements = this.option( 'value' ); this._createClaimGroupListview(); @@ -93,28 +102,29 @@ } } ); - if( claims ) { - this._initClaims( claims ); + if( statements ) { + this._initStatements( statements ); } }, /** -* Fills the listview with the initially passed claims by ordering the claims according to their -* property. +* Fills the `listview` with the initially passed `Statement`s by ordering the `Statement`s +* according to their main `Snak`'s `Property` id. * @since 0.5 * -* @param {wikibase.datamodel.ClaimGroupSet|wikibase.datamodel.StatementGroupSet} claimGroups +* @param {wikibase.datamodel.StatementGroupSet} statementGroups */ - _initClaims: function( claimGroups ) { + _initStatements: function( statementGroups ) { var self = this; - claimGroups.each( function( propertyId, claimGroup ) { - self.listview().addItem( claimGroup ); + statementGroups.each( function( propertyId, statementGroup ) { + self.listview().addItem( statementGroup ); } ); }, /** -* @see jQuery.Widget.destroy +* @inheritdoc +* @protected */ destroy: function() { this.listview().destroy(); @@ -122,8 +132,9 @@ }, /** -* Creates the listview that contains any number of claimlistviews. +* Creates the `listview` widget used to manage the `claimlistview` widgets. * @since 0.5 +* @private */ _createClaimGroupListview: function() { var self = this; @@ -148,6 +159,7 @@ /** * Toggles a specific css class on the group title node. * @since 0.5 +* @private * * @param {jQuery} $claimlistview * @param {string} cssClass @@ -164,6 +176,7 @@ /** * Adds
[MediaWiki-commits] [Gerrit] Updated claimlistview documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185166 Change subject: Updated claimlistview documentation .. Updated claimlistview documentation Change-Id: I65dc813a8b7064be4a8cbc13d46c163d895962f1 --- M lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js 1 file changed, 78 insertions(+), 48 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/66/185166/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js index 747a5ac..09c9293 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js @@ -1,48 +1,71 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < mediaw...@snater.com > - */ ( function( mw, wb, $ ) { 'use strict'; var PARENT = $.ui.TemplatedWidget; /** - * View for displaying and editing a list of statements (wb.datamodel.Statement objects). - * @since 0.4 + * View for displaying and editing a list of `wikibase.datamodel.Statement` objects by using + * `jQuery.wikibase.statementview` widgets. + * @see jQuery.wikibase.statementview + * @see wikibase.datamodel.Statement + * @class jQuery.wikibase.claimlistview * @extends jQuery.ui.TemplatedWidget + * @uses jQuery.wikibase.listview + * @uses jQuery.wikibase.listview.ListItemAdapter + * @uses jQuery.wikibase.statementview + * @uses mediaWiki + * @uses wikibase.utilities.ui + * @since 0.4 + * @licence GNU GPL v2+ + * @author H. Snater < mediaw...@snater.com > * - * @option {wikibase.datamodel.ClaimGroup|wikibase.datamodel.StatementGroup} [value] - * The list of statements to be displayed by this view. If null, the view will initialize an - * empty statementview with edit mode started. - * Default: null + * @constructor * - * @option {wb.store.EntityStore} entityStore - * - * @option {wikibase.ValueViewBuilder} valueViewBuilder - - * @option {wikibase.entityChangers.EntityChangersFactory} entityChangersFactory - * - * @option {dataTypes.DataTypeStore} dataTypeStore - * - * @event startediting: Triggered when one of the claimlistview's items enters edit mode. - *(1) {jQuery.Event} - * - * @event afterstopediting: Triggered when one of the claimlistview's items has successfully left - *edit mode. - *(1) {jQuery.Event} - *(2) {boolean} Whether pending value has been dropped or saved. - * - * @event afterremove: Triggered when one of the claimlistview's items has just been removed. - *(1) {jQuery.Event} - * - * @event toggleerror: Triggered when one of the claimlistview's items produces an error. - *(1) {jQuery.Event} + * @param {Object} options + * @param {wikibase.datamodel.ClaimGroup|wikibase.datamodel.StatementGroup} [options.value=null] + *The list of `Statement`s to be displayed by this view. If null, the view will initialize + *with edit mode being started. + * @param {wikibase.store.EntityStore} options.entityStore + *Required for dynamically gathering `Entity`/`Property` information. + * @param {wikibase.ValueViewBuilder} options.valueViewBuilder + *Required by the `snakview` interfacing a `snakview` "value" `Variation` to + *`jQuery.valueview`. + * @param {wikibase.entityChangers.EntityChangersFactory} options.entityChangersFactory + *Required to store the `Reference`s gatherd from the `referenceview`s aggregated by the + *`statementview`. + * @param {dataTypes.DataTypeStore} options.dataTypeStore + *Required by the `snakview` for retrieving and evaluating a proper `dataTypes.DataType` + *object when interacting on a "value" `Variation`. +/** + * @event startediting + * Triggered when edit mode is started for one of the `statementview` widgets managed by the + * `claimlistview`. + * @param {jQuery.Event} event + */ +/** + * @event afterstopediting + * Triggered when one of the `statementview` widgets managed by the `claimlistview` has successfully + * stopped edit mode. + * @param {jQuery.Event} event + * @param {boolean} dropValue If true, the value from before edit mode has been started will be + *reinstated (basically, a cancel/save switch). + */ +/** + * @event afterremove + * Triggered after one of the `statementview` widgets managed by the `claimlistview` was removed + * from the `claimlistview`. + * @param {jQuery.Event} event + */ +/** + * @event toggleerror + * Triggered when one of the `statementview` widgets managed by the `claimlistview` produces an + * error. + * @param {jQuery.Event} event */ $.widget( 'wikibase.claimlistview', PARENT, { /** -* (Additional) default options. -* @see jQuery.Widget.options +* @inheritdoc +* @protected */
[MediaWiki-commits] [Gerrit] claimlistview: Removed obsolete _listItemWidget member - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/185162 Change subject: claimlistview: Removed obsolete _listItemWidget member .. claimlistview: Removed obsolete _listItemWidget member $.wikibase.claimview was removed, no alternative to $.wikibase.statementview is supposed to be used. Change-Id: Ifc8e3e029764920893078d39389d66ff1d40a367 --- M lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js 1 file changed, 1 insertion(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/62/185162/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js index 372e518..747a5ac 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js @@ -66,12 +66,6 @@ }, /** -* The widget to be managed by the claimlistview. -* @type {$.wikibase.statementview} -*/ - _listItemWidget: null, - - /** * @type {wb.entityChangers.ClaimsChanger} */ _claimsChanger: null, @@ -91,8 +85,6 @@ } PARENT.prototype._create.call( this ); - - this._listItemWidget = $.wikibase.statementview; this._claimsChanger = this.options.entityChangersFactory.getClaimsChanger(); @@ -174,7 +166,6 @@ */ _createListView: function() { var self = this, - listItemWidget = this._listItemWidget, statements = this.option( 'value' ), propertyId; @@ -186,7 +177,7 @@ this.$listview .listview( { listItemAdapter: new $.wikibase.listview.ListItemAdapter( { - listItemWidget: listItemWidget, + listItemWidget: $.wikibase.statementview, newItemOptionsFn: function( value ) { return { value: value || null, -- To view, visit https://gerrit.wikimedia.org/r/185162 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifc8e3e029764920893078d39389d66ff1d40a367 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] entitytermsview: Inject link to help page - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/184907 Change subject: entitytermsview: Inject link to help page .. entitytermsview: Inject link to help page - 86191 Change-Id: I15748ced5c0e82adfa887801ac6c53454eac1b15 --- M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js M lib/resources/jquery.wikibase/resources.php M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css M repo/i18n/en.json M repo/i18n/qqq.json 5 files changed, 60 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/07/184907/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js index 5241943..5c4f205 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js @@ -87,6 +87,11 @@ $entitytermsforlanguagelistviewToggler: null, /** +* @type {jQuery|null} +*/ + $entitytermsforlanguagelistviewHelp: null, + + /** * @see jQuery.ui.TemplatedWidget._create */ _create: function() { @@ -150,6 +155,10 @@ } this.$entitytermsforlanguagelistviewToggler.remove(); + + if( this.$entitytermsforlanguagelistviewHelp ) { + this.$entitytermsforlanguagelistviewHelp.remove(); + } this.element.off( '.' + this.widgetName ); this.element.removeClass( 'wikibase-entitytermsview' ); @@ -240,6 +249,41 @@ this.$entitytermsforlanguagelistviewContainer.before( this.$entitytermsforlanguagelistviewToggler ); + + // Inject link to page providing help about how to configure languages: + // TODO: Remove as soon as soon as some user-friednly mechanism is implemented to define + // user languages. + + if( mw.config.get( 'wbUserSpecifiedLanguages' ).length > 1 ) { + // User applied custom configuration, no need to show link to help page. + return; + } + + var self = this, + helpNamespace = mw.config.get( 'wgNamespaceIds' ).help, + title = new mw.Title( 'Configuring_languages', helpNamespace ); + + api + .get( { + prop: 'info', + titles: title.getPrefixedDb() + } ) + .done( function( response ) { + var cssClass = response.query.pages[1] ? '' : 'new'; + + this.$entitytermsforlanguagelistviewHelp = + $( '' ) + .addClass( 'wikibase-entitytermsview-entitytermsforlanguagelistview-configure' ) + .append( + $( '' ) + .attr( 'href', title.getUrl() ) + .addClass( cssClass ) + .text( mw.msg( + 'wikibase-entitytermsview-entitytermsforlanguagelistview-configure-link' + ) ) + ) + .insertAfter( self.$entitytermsforlanguagelistviewToggler ); + } ); }, /** diff --git a/lib/resources/jquery.wikibase/resources.php b/lib/resources/jquery.wikibase/resources.php index befe91f..363b888 100644 --- a/lib/resources/jquery.wikibase/resources.php +++ b/lib/resources/jquery.wikibase/resources.php @@ -172,9 +172,11 @@ 'jquery.ui.toggler', 'jquery.wikibase.entitytermsforlanguagelistview', 'mediawiki.api', + 'mediawiki.Title', 'mediawiki.user', ), 'messages' => array( + 'wikibase-entitytermsview-entitytermsforlanguagelistview-configure-link', 'wikibase-entitytermsview-entitytermsforlanguagelistview-toggler', 'wikibase-terms', ), diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css index 9075e89..fb0fdb1 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css @@ -54,6 +54,18 @
[MediaWiki-commits] [Gerrit] Renamed FingerprintView to EntityTermsView - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/184856 Change subject: Renamed FingerprintView to EntityTermsView .. Renamed FingerprintView to EntityTermsView Reflecting changes of the JS code in the PHP code generating the static HTML. As the term "fingerprintview" is supposed to disappear, message keys are adapted as well. Change-Id: I1821c583c61d3cf5f0ca6f15bb5f151397da8f7b --- M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguageview.js M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/jquery.wikibase/resources.php M repo/i18n/en.json M repo/i18n/qqq.json R repo/includes/View/EntityTermsView.php M repo/includes/View/EntityView.php M repo/includes/View/EntityViewFactory.php M repo/includes/View/EntityViewPlaceholderExpander.php M repo/includes/View/ItemView.php M repo/includes/View/PropertyView.php R repo/tests/phpunit/includes/View/EntityTermsViewTest.php M repo/tests/phpunit/includes/View/ItemViewTest.php M repo/tests/phpunit/includes/View/PropertyViewTest.php 15 files changed, 57 insertions(+), 57 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/56/184856/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js index c25fa46..1ce1e7f 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js @@ -153,7 +153,7 @@ entityId: self.options.entityId, entityChangersFactory: self.options.entityChangersFactory, helpMessage: mw.msg( - 'wikibase-fingerprintview-input-help-message', + 'wikibase-entitytermsforlanguageview-input-help-message', wb.getLanguageNameByCode( value.language ) ) }; diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguageview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguageview.js index fa52362..8f36f77 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguageview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguageview.js @@ -22,7 +22,7 @@ * } * * @option {string} [helpMessage] - * Default: mw.msg( 'wikibase-fingerprintview-input-help-message' ) + * Default: mw.msg( 'wikibase-entitytermsforlanguageview-input-help-message' ) * * @option {string} entityId * @@ -78,7 +78,7 @@ $aliases: '.wikibase-entitytermsforlanguageview-aliases' }, value: null, - helpMessage: mw.msg( 'wikibase-fingerprintview-input-help-message' ), + helpMessage: mw.msg( 'wikibase-entitytermsforlanguageview-input-help-message' ), entityId: null, entityChangersFactory: null }, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index 47b8107..3c777a2 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -202,7 +202,7 @@ value: value, entityId: this.options.value.getId(), entityChangersFactory: this.options.entityChangersFactory, - helpMessage: mw.msg( 'wikibase-fingerprintgroupview-input-help-message' ) + helpMessage: mw.msg( 'wikibase-entitytermsview-input-help-message' ) } ); }, diff --git a/lib/resources/jquery.wikibase/resources.php b/lib/resources/jquery.wikibase/resources.php index e3e6fd1..befe91f 100644 --- a/lib/resources/jquery.wikibase/resources.php +++ b/lib/resources/jquery.wikibase/resources.php @@ -153,7 +153,7 @@ 'wikibase.templates', ), 'messages' => array( - 'wikibase-fingerprintgroupview-input-help-message', + 'wikibase-entitytermsview-input-help-message', 'wikibase-terms', ), ), @@ -197,7 +197,7 @@ 'wikibase-entitytermsforlanguagelistview-description',
[MediaWiki-commits] [Gerrit] Removed table of content bar - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/184629 Change subject: Removed table of content bar .. Removed table of content bar - 84913 Change-Id: I817baed5d42ca650f5ba0a78a53dea606fcbfbae --- M repo/includes/EntityParserOutputGenerator.php M repo/includes/View/EntityView.php M repo/includes/View/ItemView.php M repo/resources/Resources.php M repo/resources/templates.php D repo/resources/themes/default/wikibase.toc.css 6 files changed, 0 insertions(+), 121 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/29/184629/1 diff --git a/repo/includes/EntityParserOutputGenerator.php b/repo/includes/EntityParserOutputGenerator.php index 38b85ee..6a883da 100644 --- a/repo/includes/EntityParserOutputGenerator.php +++ b/repo/includes/EntityParserOutputGenerator.php @@ -336,7 +336,6 @@ // make css available for JavaScript-less browsers $parserOutput->addModuleStyles( array( 'wikibase.common', - 'wikibase.toc', 'jquery.ui.core', 'jquery.wikibase.statementview', 'jquery.wikibase.toolbar', diff --git a/repo/includes/View/EntityView.php b/repo/includes/View/EntityView.php index 4c16959..90ddaa7 100644 --- a/repo/includes/View/EntityView.php +++ b/repo/includes/View/EntityView.php @@ -163,7 +163,6 @@ $entity, $this->getHtmlForTermBox( $entityRevision ) ); - $html .= $this->getHtmlForToc(); wfProfileOut( __METHOD__ ); return $html; @@ -196,46 +195,6 @@ $this->textInjector, $this->editable ); - } - - /** -* Builds and returns the HTML for the toc. -* -* @return string -*/ - private function getHtmlForToc() { - $tocSections = $this->getTocSections(); - - if ( count( $tocSections ) < 3 ) { - // MediaWiki core doesn't show a TOC unless there are at least 3 sections, so we - //shouldn't either. - return ''; - } - - $tocContent = ''; - $i = 0; - - foreach ( $tocSections as $id => $message ) { - $tocContent .= $this->templateFactory->render( 'wb-entity-toc-section', - $i++, - $id, - wfMessage( $message )->text() - ); - } - - return $this->templateFactory->render( 'wb-entity-toc', - wfMessage( 'toc' )->text(), - $tocContent - ); - } - - /** -* Returns the sections that should displayed in the toc. -* -* @return string[] array( link target => system message key ) -*/ - protected function getTocSections() { - return array(); } /** diff --git a/repo/includes/View/ItemView.php b/repo/includes/View/ItemView.php index e97569a..41c0740 100644 --- a/repo/includes/View/ItemView.php +++ b/repo/includes/View/ItemView.php @@ -83,19 +83,6 @@ } /** -* @see EntityView::getTocSections -*/ - protected function getTocSections() { - $array = parent::getTocSections(); - $array['claims'] = 'wikibase-statements'; - foreach ( $this->siteLinkGroups as $group ) { - $id = htmlspecialchars( 'sitelinks-' . $group, ENT_QUOTES ); - $array[$id] = 'wikibase-sitelinks-' . $group; - } - return $array; - } - - /** * Builds and returns the HTML representing a WikibaseEntity's site-links. * * @since 0.1 diff --git a/repo/resources/Resources.php b/repo/resources/Resources.php index 3f8bfc4..4f2c55c 100644 --- a/repo/resources/Resources.php +++ b/repo/resources/Resources.php @@ -264,11 +264,6 @@ ) ), - 'wikibase.toc' => $moduleTemplate + array( - 'styles' => array( - 'themes/default/wikibase.toc.css', - ), - ), ); if ( defined( 'ULS_VERSION' ) ) { diff --git a/repo/resources/templates.php b/repo/resources/templates.php index 1a5657c..0ef231b 100644 --- a/repo/resources/templates.php +++ b/repo/resources/templates.php @@ -31,24 +31,6 @@ HTML; - $templates['wb-entity-toc'] = -<< - - $1 - - $2 - -HTML; - -// $1: Index of the section -// $2: Target of the link -// $3: Text of the link - $templa
[MediaWiki-commits] [Gerrit] entitytermsview: Fix table header - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/184580 Change subject: entitytermsview: Fix table header .. entitytermsview: Fix table header Change-Id: Ia094cf1907e7d973edbbdf1402e8046cf2817ef7 --- M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js M repo/resources/jquery/jquery.sticknode.js 3 files changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/80/184580/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js index 6067682..8bcaa58 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js @@ -65,6 +65,7 @@ '' // entitytermsforlanguageview ], templateShortCuts: { + $header: '.wikibase-entitytermsforlanguagelistview-header', $listview: '.wikibase-entitytermsforlanguagelistview-listview' }, value: [], diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js index 68f92ce..8c9e581 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js @@ -259,6 +259,11 @@ entityId: this.options.entityId, entityChangersFactory: this.options.entityChangersFactory } ); + + this.$entitytermsforlanguagelistview.data( 'entitytermsforlanguagelistview' ) + .$header.sticknode( { + $container: this.$entitytermsforlanguagelistview + } ); }, /** diff --git a/repo/resources/jquery/jquery.sticknode.js b/repo/resources/jquery/jquery.sticknode.js index 69e549e..a1f5aba 100644 --- a/repo/resources/jquery/jquery.sticknode.js +++ b/repo/resources/jquery/jquery.sticknode.js @@ -203,6 +203,17 @@ .css( 'width', this.$node.width() ) .css( 'position', 'fixed' ) .css( 'z-index', '1'); + + if( this._$clone.css( 'display' ) === 'table-header-group' ) { + var $original = this._$clone.find( '*' ); + + this.$node.find( '*' ).each( function( i ) { + var $node = $( this ); + if( $node.css( 'display' ) === 'table-cell' ) { + $node.width( $original.eq( i ).width() + 'px' ); + } + } ); + } }, _unfix: function() { -- To view, visit https://gerrit.wikimedia.org/r/184580 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia094cf1907e7d973edbbdf1402e8046cf2817ef7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implemented link to toggle language list - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/184340 Change subject: Implemented link to toggle language list .. Implemented link to toggle language list - 86193 Change-Id: I3b2afe8d32a0f6ebbfa9a84b31315a8162b5a366 --- M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js M lib/resources/jquery.wikibase/resources.php M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/entitytermsview.js M repo/i18n/en.json M repo/i18n/qqq.json M repo/includes/View/EntityViewPlaceholderExpander.php 7 files changed, 85 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/40/184340/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js index 0d39a6c..68f92ce 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js @@ -87,6 +87,11 @@ $entitytermsforlanguagelistview: null, /** +* @type {jQuery} +*/ + $entitytermsforlanguagelistviewToggler: null, + + /** * @see jQuery.ui.TemplatedWidget._create */ _create: function() { @@ -111,6 +116,10 @@ } this._createEntitytermsforlanguagelistview(); + + // TODO: Remove as soon as drop-down edit buttons are implemented. The language list may + // then be shown (without directly switching to edit mode) using the drop down menu. + this._createEntiytermsforlanguagelistviewToggler(); var self = this; @@ -159,12 +168,57 @@ this.$entitytermsforlanguagelistview.remove(); } + this.$entitytermsforlanguagelistviewToggler.remove(); + this.element.off( '.' + this.widgetName ); this.element.removeClass( 'wikibase-entitytermsview' ); PARENT.prototype.destroy.call( this ); }, /** +* Creates the dedicated toggler for showing/hiding the list of entity terms. This function is +* supposed to be removed as soon as drop-down edit buttons are implemented with the mechanism +* toggling the list's visibility while not starting edit mode will be part of the drop-down +* menu. +* @private +*/ + _createEntiytermsforlanguagelistviewToggler: function() { + var api = new mw.Api(); + + this.$entitytermsforlanguagelistviewToggler = $( '' ) + .addClass( 'wikibase-entitytermsview-entitytermsforlanguagelistview-toggler' ) + .text( mw.msg( 'wikibase-entitytermsview-entitytermsforlanguagelistview-toggler' ) ) + .toggler( { + $subject: this.$entitytermsforlanguagelistviewContainer + } ) + .on( 'toggleranimation.' + this.widgetName, function( event, params ) { + if( mw.user.isAnon() ) { + $.cookie( + 'wikibase-entiytermsview-showEntitytermslistview', + params.visibility, + { expires: 365, path: '/' } + ); + } else { + api.postWithToken( 'options', { + action: 'options', + optionname: 'wikibase-entiytermsview-showEntitytermslistview', + optionvalue: params.visibility ? '1' : '0' + } ) + .done( function() { + mw.user.options.set( + 'wikibase-entiytermsview-showEntitytermslistview', + params.visibility ? '1' : '0' + ); + } ); + } + } ); + + this.$entitytermsforlanguagelistviewContainer.before( + this.$entitytermsforlanguagelistviewToggler + ); + }, + + /** * @return {jQuery.wikibase.entitytermsforlanguagelistview} * @private */ diff --git a/lib/resources/jquery.wikibase/resources.php b/lib/resources/jquery.wikibase/resources.php index 2df0616..410ea80
[MediaWiki-commits] [Gerrit] Altered initialization order in entityview widgets - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183852 Change subject: Altered initialization order in entityview widgets .. Altered initialization order in entityview widgets The "create" event is supposed to be triggered after all sub-components have been created an initialized. Change-Id: I1ba7f97fca9e5e48eb155a829e38637ad326aef5 --- M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/jquery.wikibase/jquery.wikibase.itemview.js M lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js 3 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/183852/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index d889c39..bb09e47 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -129,8 +129,6 @@ this.option( 'languages', this.options.languages ); - PARENT.prototype._create.call( this ); - this.element.data( $.wikibase.entityview.prototype.widgetName, this ); this.$toc = $( '.toc', this.element ); @@ -140,6 +138,8 @@ this._initAliases(); this._initFingerprints(); + PARENT.prototype._create.call( this ); + this._attachEventHandlers(); }, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js index 56e8610..e7fa03c 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.itemview.js @@ -34,9 +34,9 @@ * @protected */ _create: function() { - this._initEntityview(); this._initStatements(); this._initSiteLinks(); + this._initEntityview(); }, /** diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js index dfaa26b..f7a6c59 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.propertyview.js @@ -39,9 +39,9 @@ * @protected */ _create: function() { - this._initEntityview(); this._initDataType(); this._initStatements(); + this._initEntityview(); }, /** -- To view, visit https://gerrit.wikimedia.org/r/183852 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1ba7f97fca9e5e48eb155a829e38637ad326aef5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Using textarea for entering description - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183866 Change subject: Using textarea for entering description .. Using textarea for entering description requires https://github.com/wmde/ValueView/pull/142 - 86192 Change-Id: Ieca1e826be2e113bee7b2c6a3776fa276d66f5cd --- M lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css 4 files changed, 11 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/66/183866/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js b/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js index 90e92db..8cdaffc 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js @@ -125,7 +125,7 @@ return; } - var $input = $( '', { + var $input = $( '', { // TODO: Inject correct placeholder via options placeholder: mw.msg( 'wikibase-description-edit-placeholder-language-aware', @@ -142,7 +142,9 @@ } if( $.fn.inputautoexpand ) { - $input.inputautoexpand(); + $input.inputautoexpand( { + expandHeight: true + } ); } this.$text.empty().append( $input ); diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js index cf3af83..6067682 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js @@ -338,7 +338,7 @@ $.each( ['label', 'description'], function() { var $view = entitytermsforlanguageview['$' + this + 'view'], - autoExpandInput = $view.find( 'input' ).data( 'inputautoexpand' ); + autoExpandInput = $view.find( 'input,textarea' ).data( 'inputautoexpand' ); if( autoExpandInput ) { autoExpandInput.options( { diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css index c3e2bbd..8893502 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css @@ -6,7 +6,8 @@ background-color: inherit; } -.wikibase-descriptionview input { +.wikibase-descriptionview input, +.wikibase-descriptionview textarea { font-family: inherit; font-size: inherit; } diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css index 38d32c7..d2557b4 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css @@ -83,6 +83,10 @@ white-space: nowrap; } +.wikibase-entitytermsforlanguagelistview .wikibase-entitytermsforlanguagelistview-listview .wikibase-entitytermsforlanguageview textarea { + white-space: normal; /* IE */ +} + .wikibase-entitytermsforlanguagelistview .wikibase-entitytermsforlanguagelistview-listview .wikibase-entitytermsforlanguageview .wikibase-entitytermsforlanguageview-label input, .wikibase-entitytermsforlanguagelistview .wikibase-entitytermsforlanguagelistview-listview .wikibase-entitytermsforlanguageview .wikibase-entitytermsforlanguageview-description input { border: 0; -- To view, visit https://gerrit.wikimedia.org/r/183866 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieca1e826be2e113bee7b2c6a3776fa276d66f5cd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] tagadata: Fixed tag detection on blur - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183502 Change subject: tagadata: Fixed tag detection on blur .. tagadata: Fixed tag detection on blur Having initialized multiple tagadata widget, the helper tag was removed when blurring it in the tagadata instance that is not the last in the DOM structure. Change-Id: Iba7d1879f432f888d5457654e931576113832947 --- M repo/resources/jquery.ui/jquery.ui.tagadata.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/02/183502/1 diff --git a/repo/resources/jquery.ui/jquery.ui.tagadata.js b/repo/resources/jquery.ui/jquery.ui.tagadata.js index a3359ce..7eccdeb 100644 --- a/repo/resources/jquery.ui/jquery.ui.tagadata.js +++ b/repo/resources/jquery.ui/jquery.ui.tagadata.js @@ -384,7 +384,7 @@ // remove tag if it is empty already: if( self._formatLabel( $input.val() ) === '' && self.getTags().length > 1 - && !$tag.is( '.tagadata-choice:last' ) + && !$tag.is( self.element.children( '.tagadata-choice' ).last() ) ) { self.removeTag( $tag ); } -- To view, visit https://gerrit.wikimedia.org/r/183502 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iba7d1879f432f888d5457654e931576113832947 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Rearranged entity view header - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183498 Change subject: Rearranged entity view header .. Rearranged entity view header This change is the first step in rearranging the entity view's header according to the new UI layout. Major aspects: - Editable entity terms (as well as entity terms in additional languages) are displayed in a table below the entity header containing the entity terms in the UI language. By default, the table is hidden on page load. - Added user setting to show entity terms on page load. - Removed dedicated labelview, descriptionview, aliasesview for altering the entity terms in the UI language from the static header section. - Instead of the entity terms in the additional languages only, the entity terms of the UI language are wrapped in entitytermsview as well. - Removed TermBoxView.php as the logic is merged with the one FingerprintView.php and the need to render certain components (label-/description-/aliasesview) twice is removed. - Added updated CSS definitions to parent widgets removing definitions too specific from labelview and descriptionview in particular. - Removed "wikibase-firstHeading" template cloning native "firstHeading" DOM element. - Removed table of content item pointing to the entity terms since the entity terms are integrated into the header section. - Removed obsolete toolbar definitions for label-, description- and aliasesview. Refers to ->75656, ->75657. Change-Id: I21c7d4a466b8da7006b1a9215f85b7b5924ba71e --- M lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js M lib/resources/jquery.wikibase/jquery.wikibase.descriptionview.js M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguageview.js M lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/jquery.wikibase/jquery.wikibase.labelview.js M lib/resources/jquery.wikibase/resources.php M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.aliasesview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguageview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.labelview.css D lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/aliasesview.js D lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/descriptionview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/entitytermsview.js D lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/labelview.js M lib/resources/jquery.wikibase/toolbar/controller/resources.php M lib/resources/wikibase.css M repo/Wikibase.hooks.php M repo/i18n/en.json M repo/i18n/qqq.json M repo/includes/View/EntityView.php M repo/includes/View/EntityViewPlaceholderExpander.php M repo/includes/View/FingerprintView.php D repo/includes/View/TermBoxView.php M repo/resources/Resources.php M repo/resources/templates.php M repo/resources/wikibase.ui.entityViewInit.js M repo/tests/phpunit/includes/View/EntityViewPlaceholderExpanderTest.php M repo/tests/phpunit/includes/View/EntityViewTest.php M repo/tests/phpunit/includes/View/FingerprintViewTest.php D repo/tests/phpunit/includes/View/TermBoxViewTest.php 34 files changed, 701 insertions(+), 1,267 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/98/183498/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js b/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js index 4decdff..a3270e7 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js @@ -27,13 +27,11 @@ template: 'wikibase-aliasesview', templateParams: [ '', // additional class - mw.msg( 'wikibase-aliases-label' ), // label '', // list items '' // toolbar ], templateShortCuts: { - '$label': '.wikibase-aliasesview-label', - '$list': 'ul' + $list: 'ul' }, value: null, helpMessage: mw.msg( 'wikibase-aliases-input-help-message' ), @@ -54,7 +52,6 @@ PARENT.prototype._create.call( this ); this.element.removeClass( 'wb-empty' ); - this.$label.text( mw.msg( 'wikibase-aliases-labe
[MediaWiki-commits] [Gerrit] Do not trigger "change" event when handling empty elements - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183456 Change subject: Do not trigger "change" event when handling empty elements .. Do not trigger "change" event when handling empty elements Retains "disabled" state on "remove" toolbars. ->76849 Change-Id: I7210719ddc87af3199a1a5412db7a283f97d0b12 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/56/183456/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js index bba89d1..47b4f0c 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js @@ -173,9 +173,12 @@ .on( 'listviewitemremoved.' + this.widgetName + ' listviewitemadded.' + this.widgetName, - function( event ) { + function( event, sitelinkview ) { self._refreshCounter(); - self._trigger( 'change' ); + if( sitelinkview ) { + // Do not trigger "change" event when handling empty elements. + self._trigger( 'change' ); + } } ); }, -- To view, visit https://gerrit.wikimedia.org/r/183456 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7210719ddc87af3199a1a5412db7a283f97d0b12 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] referenceview edit toolbar: Have "save" button disabled init... - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183451 Change subject: referenceview edit toolbar: Have "save" button disabled initially .. referenceview edit toolbar: Have "save" button disabled initially Change-Id: Iebe109cf0fea61b1818c1480733c9da8a7b7db23 --- M lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/51/183451/1 diff --git a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js index b14206f..f46ee13 100644 --- a/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js +++ b/lib/resources/jquery.wikibase/toolbar/controller/definitions/edittoolbar/referenceview.js @@ -51,7 +51,7 @@ } } ); }, - referenceviewchange: function( event ) { + 'referenceviewchange referenceviewafterstartediting': function( event ) { var $referenceview = $( event.target ), referenceview = $referenceview.data( 'referenceview' ), edittoolbar = $referenceview.data( 'edittoolbar' ), -- To view, visit https://gerrit.wikimedia.org/r/183451 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iebe109cf0fea61b1818c1480733c9da8a7b7db23 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] entityselector: Adjusted member name to changes in ValueView - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183031 Change subject: entityselector: Adjusted member name to changes in ValueView .. entityselector: Adjusted member name to changes in ValueView Change-Id: Idf52bda78ec624672010850a5990516b1981ddff --- M lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/31/183031/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js index 99ac7fd..4066270 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js @@ -179,7 +179,7 @@ this._select( null ); clearTimeout( this.__searching ); - this.__searching = setTimeout( function() { + this._searching = setTimeout( function() { self.search( event ) .done( function( suggestions, requestTerm ) { if( !suggestions.length || self.element.val() !== requestTerm ) { -- To view, visit https://gerrit.wikimedia.org/r/183031 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idf52bda78ec624672010850a5990516b1981ddff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] siteselector: Factored out _considerSuggestion() - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183027 Change subject: siteselector: Factored out _considerSuggestion() .. siteselector: Factored out _considerSuggestion() Change-Id: I1d892a666df9111d7a50da8bc56eefd8b5fe1a1d --- M lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js 1 file changed, 24 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/27/183027/1 diff --git a/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js b/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js index 771962a..2c5ceaf 100644 --- a/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js +++ b/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js @@ -192,26 +192,36 @@ } var suggestedSites = $.grep( source, function( site ) { - var check = [ - site.getId(), - site.getShortName(), - site.getName(), - site.getShortName() + ' (' + site.getId() + ')' - ]; - - for( var i = 0; i < check.length; i++ ) { - if( check[i].toLowerCase().indexOf( self._term.toLowerCase() ) === 0 ) { - return true; - } - } - - return false; + return self._considerSuggestion( site ); } ); return deferred.resolve( suggestedSites, term ).promise(); }, /** +* @protected +* +* @param {wikibase.Site} site +* @return {boolean} +*/ + _considerSuggestion: function( site ) { + var check = [ + site.getId(), + site.getShortName(), + site.getName(), + site.getShortName() + ' (' + site.getId() + ')' + ]; + + for( var i = 0; i < check.length; i++ ) { + if( check[i].toLowerCase().indexOf( this._term.toLowerCase() ) === 0 ) { + return true; + } + } + + return false; + }, + + /** * @see jQuery.ui.suggester._createMenuItemFromSuggestion */ _createMenuItemFromSuggestion: function( suggestion, requestTerm ) { -- To view, visit https://gerrit.wikimedia.org/r/183027 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1d892a666df9111d7a50da8bc56eefd8b5fe1a1d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] sitelinklistview: No "afterstopediting" event for pending items - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/183015 Change subject: sitelinklistview: No "afterstopediting" event for pending items .. sitelinklistview: No "afterstopediting" event for pending items Change-Id: I330a9b2b1ea732ca2e4fd4a04599ceef338e3e9b --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js 1 file changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/15/183015/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js index 6474e84..bba89d1 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js @@ -786,8 +786,6 @@ } self._refreshCounter(); - - self._trigger( 'afterstopediting', null, [dropValue] ); } ); self._refreshCounter(); -- To view, visit https://gerrit.wikimedia.org/r/183015 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I330a9b2b1ea732ca2e4fd4a04599ceef338e3e9b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fixed $.ui.closeable QUnit tests - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180809 Change subject: Fixed $.ui.closeable QUnit tests .. Fixed $.ui.closeable QUnit tests Change-Id: I050ab64b1e2795ae322af3830b5f4d96e3eab174 --- M repo/resources/jquery.ui/jquery.ui.closeable.js M repo/tests/qunit/jquery.ui/jquery.ui.closeable.tests.js 2 files changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/09/180809/1 diff --git a/repo/resources/jquery.ui/jquery.ui.closeable.js b/repo/resources/jquery.ui/jquery.ui.closeable.js index e852e2f..3ec74bf 100644 --- a/repo/resources/jquery.ui/jquery.ui.closeable.js +++ b/repo/resources/jquery.ui/jquery.ui.closeable.js @@ -63,7 +63,7 @@ */ setContent: function( $content, cssClasses ) { this.option( '$content', $content || null ); - this.option( 'cssClass', cssClasses || null ); + this.option( 'cssClass', cssClasses || '' ); this._trigger( 'update' ); }, diff --git a/repo/tests/qunit/jquery.ui/jquery.ui.closeable.tests.js b/repo/tests/qunit/jquery.ui/jquery.ui.closeable.tests.js index 91ff319..6aae164 100644 --- a/repo/tests/qunit/jquery.ui/jquery.ui.closeable.tests.js +++ b/repo/tests/qunit/jquery.ui/jquery.ui.closeable.tests.js @@ -15,7 +15,7 @@ .closeable( options || {} ); } -QUnit.module( 'jquery.ui.tagadata', QUnit.newMwEnvironment( { +QUnit.module( 'jquery.ui.closeable', QUnit.newMwEnvironment( { teardown: function() { $( '.test_closeable' ).each( function() { var $closeable = $( this ), @@ -54,14 +54,14 @@ closeable = $closeable.data( 'closeable' ); assert.ok( - $closeable.option( '$content' ) instanceof $, + closeable.option( '$content' ) instanceof $, 'Instantiated widget with initial content.' ); closeable.$close.trigger( 'click' ); assert.strictEqual( - $closeable.option( '$content' ), + closeable.option( '$content' ), null, 'Removed content after clicking "close" anchor.' ); @@ -99,7 +99,7 @@ 'Set CSS class.' ); - closeable.setContent( $content, 'cssClass' ); + closeable.setContent( null, null ); assert.strictEqual( closeable.option( '$content' ), -- To view, visit https://gerrit.wikimedia.org/r/180809 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I050ab64b1e2795ae322af3830b5f4d96e3eab174 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] sitelinkview: Fixed assumption about rankselector being init... - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180810 Change subject: sitelinkview: Fixed assumption about rankselector being initialized .. sitelinkview: Fixed assumption about rankselector being initialized Change-Id: Ic3daa4bc999df8dae740e2eb8f973433c96f6686 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js 1 file changed, 8 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/10/180810/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js index 72bf6ba..09b9c42 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js @@ -86,7 +86,7 @@ _isInEditMode: false, /** -* @type {jQuery.wikibase.badgeselector} +* @type {jQuery.wikibase.badgeselector|null} */ _badgeselector: null, @@ -279,7 +279,9 @@ pagesuggester.disable(); $pageNameInput.hide(); - if( !this.options.value || !this.options.value.getBadges().length ) { + if( + this._badgeselector && ( !this.options.value || !this.options.value.getBadges().length ) + ) { this._badgeselector.element.hide(); } @@ -292,10 +294,12 @@ .attr( 'lang', site.getLanguageCode() ) .attr( 'dir', site.getLanguageDirection() ) .show(); - self._badgeselector.element.show(); } else { $pageNameInput.hide(); - self._badgeselector.element.hide(); + } + + if( self._badgeselector ) { + self._badgeselector.element[site ? 'show' : 'hide'](); } pagesuggester[site ? 'enable' : 'disable'](); -- To view, visit https://gerrit.wikimedia.org/r/180810 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic3daa4bc999df8dae740e2eb8f973433c96f6686 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added "encapsulate" option to TemplatedWidget - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180769 Change subject: Added "encapsulate" option to TemplatedWidget .. Added "encapsulate" option to TemplatedWidget Prevents events from bubbling up the DOM tree unnecessarily. ->78149 Change-Id: Iee90bfa54e8fdb0692d4bbe21ef2fd2d60aaccb8 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js M lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js M repo/resources/jquery.ui/jquery.ui.EditableTemplatedWidget.js M repo/resources/jquery.ui/jquery.ui.TemplatedWidget.js 6 files changed, 66 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/69/180769/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js index 0e9ffd5..f394465 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgrouplistview.js @@ -76,7 +76,8 @@ }, _createListview: function() { - var self = this; + var self = this, + prefix = $.wikibase.sitelinkgroupview.prototype.widgetEventPrefix; this.$listview = this.element.find( '.wb-listview' ); @@ -98,7 +99,11 @@ }; } } ), - value: self.options.value || null + value: self.options.value || null, + encapsulate: true + } ) + .on( prefix + 'disable.' + this.widgetName, function( event ) { + event.stopPropagation(); } ); }, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js index c275f48..4e1068f 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js @@ -156,25 +156,11 @@ this.$sitelinklistview .on( prefix + 'change.' + this.widgetName, function( event ) { - event.stopPropagation(); self._trigger( 'change' ); } ) .on( prefix + 'toggleerror.' + this.widgetName, function( event, error ) { - event.stopPropagation(); self.setError( error ); } ) - .on( - [ - prefix + 'create.' + this.widgetName, - prefix + 'afterstartediting.' + this.widgetName, - prefix + 'stopediting.' + this.widgetName, - prefix + 'afterstopediting.' + this.widgetName, - prefix + 'disable.' + this.widgetName - ].join( ' ' ), - function( event ) { - event.stopPropagation(); - } - ) .sitelinklistview( { value: this._getSiteLinksOfGroup(), allowedSiteIds: this.options.value @@ -183,7 +169,8 @@ entityStore: this.options.entityStore, siteLinksChanger: this.options.siteLinksChanger, eventSingleton: this._eventSingleton, - $counter: this.$counter + $counter: this.$counter, + encapsulate: true } ); }, diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js index 6474e84..8b88a79 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js @@ -137,7 +137,8 @@ } } ), value: self.options.value || null, - listItemNodeName: 'LI' + listItemNodeName: 'LI', + encapsulate: true } ) .on( prefix + 'change.' + this.widgetName, function( event ) { event.stopPropagation(); diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js index 72bf6ba..ad49e37 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
[MediaWiki-commits] [Gerrit] Removed obsolete caseInsensitive option from highlightSubstr... - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180445 Change subject: Removed obsolete caseInsensitive option from highlightSubstring calls .. Removed obsolete caseInsensitive option from highlightSubstring calls caseInsensitive options was remove in ValueView 0.9.0 and replaced by "caseSensitive" defaulting to false. Change-Id: I9d91ed0e59f873d5ce1955a33061eed7a5f230bb --- M lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js M lib/resources/jquery.wikibase/jquery.wikibase.pagesuggester.js 2 files changed, 3 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/45/180445/1 diff --git a/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js b/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js index d9b027e..771962a 100644 --- a/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js +++ b/lib/resources/jquery.wikibase-shared/jquery.wikibase.siteselector.js @@ -230,12 +230,8 @@ * @return {string} */ _createItemLabel: function( site, requestTerm ) { - return util.highlightSubstring( requestTerm, site.getShortName(), { - caseInsensitive: true - } ) - + ' (' + util.highlightSubstring( requestTerm, site.getId(), { - caseInsensitive: true - } ) + ')'; + return util.highlightSubstring( requestTerm, site.getShortName() ) + + ' (' + util.highlightSubstring( requestTerm, site.getId() ) + ')'; }, /** diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.pagesuggester.js b/lib/resources/jquery.wikibase/jquery.wikibase.pagesuggester.js index d501b82..c2d3040 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.pagesuggester.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.pagesuggester.js @@ -117,9 +117,7 @@ */ _createMenuItemFromSuggestion: function( suggestion, requestTerm ) { return new $.ui.ooMenu.Item( - util.highlightSubstring( requestTerm, suggestion, { - caseInsensitive: true - } ), + util.highlightSubstring( requestTerm, suggestion ), suggestion ); } -- To view, visit https://gerrit.wikimedia.org/r/180445 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9d91ed0e59f873d5ce1955a33061eed7a5f230bb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Renamed fingerprintview widgets - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180438 Change subject: Renamed fingerprintview widgets .. Renamed fingerprintview widgets fingerprintview widgets were named incorrectly. As "Fingerprint" is the aggregation of labels, descriptions and aliases in all languages, fingerprintview should have been what was labeled fingerprintgroupview. While there is no fictitious term for the aggregation of label, description and aliases of a single language and the term "Fingerprint" does not pursue a solid concept, the UI components have been renamed in a more obvious fashion. "entitytermsview" aggregates all term related objects of an entity. (Fingerprint is actually an aggregation of wikibase.datamodel.Term(Map) and wikibase.datamodel.MultiTerm(Map) objects.) This change advances the effort of renaming/removing the term "Fingerprint". ->75655 Change-Id: I084b6a11f8ddb7930b145e7852b7a5e66daa0a32 --- M lib/resources/Resources.php R lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguage.js R lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.js A lib/resources/jquery.wikibase/jquery.wikibase.entitytermsview.js M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js D lib/resources/jquery.wikibase/jquery.wikibase.fingerprintgroupview.js M lib/resources/jquery.wikibase/resources.php A lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguage.css A lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css A lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css D lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css D lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintlistview.css D lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintview.css A lib/tests/qunit/jquery.wikibase/jquery.wikibase.entitytermsforlanguage.tests.js A lib/tests/qunit/jquery.wikibase/jquery.wikibase.entitytermsforlanguagelistview.tests.js A lib/tests/qunit/jquery.wikibase/jquery.wikibase.entitytermsview.tests.js D lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintgroupview.tests.js D lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintlistview.tests.js D lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintview.tests.js M lib/tests/qunit/jquery.wikibase/resources.php M repo/includes/View/TermBoxView.php M repo/resources/templates.php M repo/resources/wikibase.ui.entityViewInit.js 23 files changed, 1,226 insertions(+), 1,205 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/38/180438/1 diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php index fd3e2ec..610ef89 100644 --- a/lib/resources/Resources.php +++ b/lib/resources/Resources.php @@ -34,9 +34,9 @@ 'jquery.wikibase/themes/default/jquery.wikibase.aliasesview.css', 'jquery.wikibase/themes/default/jquery.wikibase.descriptionview.css', 'jquery.wikibase/themes/default/jquery.wikibase.entityview.css', - 'jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css', - 'jquery.wikibase/themes/default/jquery.wikibase.fingerprintlistview.css', - 'jquery.wikibase/themes/default/jquery.wikibase.fingerprintview.css', + 'jquery.wikibase/themes/default/jquery.wikibase.entitytermsview.css', + 'jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguagelistview.css', + 'jquery.wikibase/themes/default/jquery.wikibase.entitytermsforlanguage.css', 'jquery.wikibase/themes/default/jquery.wikibase.labelview.css', 'jquery.wikibase/themes/default/jquery.wikibase.sitelinkgrouplistview.css', 'jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css', diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguage.js similarity index 94% rename from lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js rename to lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguage.js index 889bb40..435c96c 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entitytermsforlanguage.js @@ -47,9 +47,9 @@ *- {jQuery.Event} *- {Error|null} */ -$.widget( 'wikibase.fingerprintview', PARENT, { +$.widget( 'wikibase.entitytermsforlanguage', PARENT, { options: { - template: 'wikibase
[MediaWiki-commits] [Gerrit] Removed toolbarcontroller toolbar restrictions - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180423 Change subject: Removed toolbarcontroller toolbar restrictions .. Removed toolbarcontroller toolbar restrictions Removing the restriction to specific toolbar types allows adding additional/custom toolbar types. (It was already possible to register additional toolbar types but those could not be initialized when creating the toolbarcontroller widget. This change removes the consistency error.) Change-Id: Ia722429712207ea334d1f00fc7045db2ba31db9a --- M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.js M repo/resources/wikibase.ui.entityViewInit.js 2 files changed, 43 insertions(+), 58 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/23/180423/1 diff --git a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.js b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.js index 933f410..f5d6f35 100644 --- a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.js +++ b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.js @@ -6,14 +6,6 @@ 'use strict'; /** -* Available toolbar types. -* TODO: create a registry for allowing adding additional toolbar types -* -* @type {string[]} -*/ - var TOOLBAR_TYPES = ['addtoolbar', 'edittoolbar', 'removetoolbar', 'movetoolbar']; - - /** * Toolbar controller widget * * The toolbar controller initializes and manages toolbar widgets. Toolbar definitions are @@ -28,31 +20,18 @@ * * @since 0.4 * -* @option addtoolbar {string[]} List of toolbar definition ids/widget names that are registered -* as "add" toolbars and shall be initialized. -* Default: [] +* @constructor * -* @option edittoolbar {string[]} List of toolbar definition ids/widget names that are -* registered as "edit" toolbars and shall be initialized. -* Default: [] -* -* @option removetoolbar {string[]} List of toolbar definition ids/widget names that are -* registered as "remove" toolbars and shall be initialized. -* Default: [] -* -* @option movetoolbar {string[]} List of toolbar definition ids/widget names that are -* registered as "move" toolbars and shall be initialized. -* Default: [] +* @param {Object} [toolbars={}] +*Lists of toolbar definition ids indexed by their corresponding toolbar type. */ $.widget( 'wikibase.toolbarcontroller', { /** -* @type {Object} +* @inheritdoc +* @protected */ options: { - addtoolbar: [], - edittoolbar: [], - removetoolbar: [], - movetoolbar: [] + toolbars: null }, /** @@ -63,12 +42,16 @@ _create: function() { var self = this; - $.each( TOOLBAR_TYPES, function( i, type ) { - $.each( self.options[type], function( j, id ) { - var def = $.wikibase.toolbarcontroller.definition( type, id ); + this.options.toolbars = this.options.toolbars || {}; + + $.each( this.options.toolbars, function( type, ids ) { + $.each( ids, function() { + var id = this, + def = $.wikibase.toolbarcontroller.definition( type, id ); if( !def ) { - throw new Error( 'Missing toolbar controller definition for "' + id + '"' ); + throw new Error( 'Missing toolbar controller definition for type "' + + type + '" with id "' + id + '"' ); } $.each( def.events, function( eventNames, callback ) { diff --git a/repo/resources/wikibase.ui.entityViewInit.js b/repo/resources/wikibase.ui.entityViewInit.js index 2aa0f75..95ad3bf 100644 --- a/repo/resources/wikibase.ui.entityViewInit.js +++ b/repo/resources/wikibase.ui.entityViewInit.js @@ -33,33 +33,35 @@ // The toolbars (defined per jquery.wikibase.toolbarcontroller.definition) that should // be initialized: var toolbarControllerConfig = { -
[MediaWiki-commits] [Gerrit] Not passing Message object into template - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180150 Change subject: Not passing Message object into template .. Not passing Message object into template The template mechanism derives from the Message system. Passing a Message instance causes the parameter getting parsed after other (plain) texts have been inserted into the assembled message (template). Consequently, parameter strings in other texts will be detected by the mechanism replacing the parameter with the Message instance. ->76673 Change-Id: If8067e5a60ffde954e10701613130e9af6848c5d --- M repo/includes/View/TermBoxView.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/50/180150/1 diff --git a/repo/includes/View/TermBoxView.php b/repo/includes/View/TermBoxView.php index 2f25831..5b14996 100644 --- a/repo/includes/View/TermBoxView.php +++ b/repo/includes/View/TermBoxView.php @@ -101,7 +101,7 @@ } $html = wfTemplate( 'wikibase-fingerprintgroupview', - $this->msg( 'wikibase-terms' ), + $this->msg( 'wikibase-terms' )->text(), wfTemplate( 'wikibase-fingerprintlistview', $tbody ), $this->sectionEditLinkGenerator->getHtmlForEditSection( 'SpecialPages', -- To view, visit https://gerrit.wikimedia.org/r/180150 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If8067e5a60ffde954e10701613130e9af6848c5d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] badgselector: Suppress badges that refer to deleted items - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180133 Change subject: badgselector: Suppress badges that refer to deleted items .. badgselector: Suppress badges that refer to deleted items There is no point in allowing to select a badge that refers to a deleted item as saving would result in the back-end triggering an item-not-found error. ->76151 Change-Id: I0463ac65699803c81150b96d569f5775f1d685a0 --- M lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js M lib/resources/jquery.wikibase/resources.php 2 files changed, 8 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/33/180133/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js b/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js index 7431b97..b021f9e 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js @@ -2,7 +2,7 @@ * @licence GNU GPL v2+ * @author H. Snater < mediaw...@snater.com > */ -( function( wb, $, mw ) { +( function( $, mw ) { 'use strict'; var PARENT = $.ui.TemplatedWidget; @@ -284,18 +284,15 @@ term = item && item.getFingerprint().getLabelFor( self.options.languageCode ), label = term && term.getText(); + if( !item ) { + return true; + } + var $item = $( '' ) .on( 'click.' + self.widgetName, function( event ) { event.preventDefault(); - } ); - - if( item ) { - $item.text( label || itemId ); - } else { - $item.append( - wb.utilities.ui.buildMissingEntityInfo( itemId, wb.datamodel.Item.TYPE ) - ); - } + } ) + .text( label || itemId ); $( '' ) .addClass( self.widgetBaseClass + '-menuitem-' + itemId ) @@ -543,4 +540,4 @@ } } ); -}( wikibase, jQuery, mediaWiki ) ); +}( jQuery, mediaWiki ) ); diff --git a/lib/resources/jquery.wikibase/resources.php b/lib/resources/jquery.wikibase/resources.php index f193584..696d46d 100644 --- a/lib/resources/jquery.wikibase/resources.php +++ b/lib/resources/jquery.wikibase/resources.php @@ -49,9 +49,7 @@ 'dependencies' => array( 'jquery.ui.menu', 'jquery.ui.TemplatedWidget', - 'wikibase.datamodel', 'wikibase.templates', - 'wikibase.utilities', ), ), -- To view, visit https://gerrit.wikimedia.org/r/180133 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0463ac65699803c81150b96d569f5775f1d685a0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] sitelinkview: Improved pagesuggester performance - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/180128 Change subject: sitelinkview: Improved pagesuggester performance .. sitelinkview: Improved pagesuggester performance (requires https://github.com/wmde/ValueView/pull/137) Change-Id: Ibbff182edb7fa30bfc994a7a3e2802fb16d1148c --- M composer.json M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js 2 files changed, 7 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/28/180128/1 diff --git a/composer.json b/composer.json index d6e4e38..a202db7 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "data-values/data-types": "~0.4.0", "data-values/serialization": "~1.0", "data-values/javascript": "~0.6.0", - "data-values/value-view": "~0.9.0", + "data-values/value-view": "~0.9.1", "wikibase/data-model": "~2.4", "wikibase/data-model-javascript": "~1.0", diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js index 0eaf996..6265667 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js @@ -217,10 +217,14 @@ dir: dir } ).pagesuggester( pageNameInputOptions ); + var pagesuggester = $pageNameInput.data( 'pagesuggester' ); + $pageNameInput .on( 'pagesuggesterchange.' + this.widgetName, function( event ) { - self.setError(); - self._trigger( 'change' ); + if( !pagesuggester.isSearching() ) { + self.setError(); + self._trigger( 'change' ); + } } ); this.$link.find( '.wikibase-sitelinkview-page' ).empty().append( $pageNameInput ); @@ -236,8 +240,6 @@ .siteselector( { source: self.options.getAllowedSites } ); - - var pagesuggester = $pageNameInput.data( 'pagesuggester' ); // Disable initially and wait for valid site input: pagesuggester.disable(); -- To view, visit https://gerrit.wikimedia.org/r/180128 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibbff182edb7fa30bfc994a7a3e2802fb16d1148c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Updated sitelinkview styling - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179913 Change subject: Updated sitelinkview styling .. Updated sitelinkview styling Updates sitelinkview styling as to the direction given by the UI mock-ups. Change-Id: Ifaeb6e93280610f2372a849f2a55eb2fdae66276 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css 3 files changed, 16 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/13/179913/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js index 0eaf996..6be3e66 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js @@ -239,8 +239,9 @@ var pagesuggester = $pageNameInput.data( 'pagesuggester' ); - // Disable initially and wait for valid site input: + // Disable and hide initially and wait for valid site input: pagesuggester.disable(); + $pageNameInput.hide(); $siteIdInput .on( 'siteselectorselected.' + this.widgetName, function( event, siteId ) { @@ -249,7 +250,10 @@ if( site ) { $pageNameInput .attr( 'lang', site.getLanguageCode() ) - .attr( 'dir', site.getLanguageDirection() ); + .attr( 'dir', site.getLanguageDirection() ) + .show(); + } else { + $pageNameInput.hide(); } pagesuggester[site ? 'enable' : 'disable'](); diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css index 74c2219..2a45eaa 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkgroupview.css @@ -17,7 +17,7 @@ } .wikibase-sitelinkgroupview.wb-edit { - background-color: #D6F3FF; + border-color: #2779aa; } .wikibase-sitelinkgroupview .wikibase-sitelinkgroupview-heading-container { diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css index d918b45..26cd215 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css @@ -28,10 +28,19 @@ } .wikibase-sitelinkview input { + background-color: transparent; + border-left: 0; + border-right: 0; + border-top: 0; margin: 0; font-family: inherit; font-size: 1em; /* prevent font size rounding errors */ box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; + outline: none; +} + +.wikibase-sitelinkview input:focus { + border-color: #0b0080; } -- To view, visit https://gerrit.wikimedia.org/r/179913 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifaeb6e93280610f2372a849f2a55eb2fdae66276 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] sitelinkview: Moved badges to the end of the line - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179911 Change subject: sitelinkview: Moved badges to the end of the line .. sitelinkview: Moved badges to the end of the line ->76215 Change-Id: I2439aeda32c281bceb6ffdad80b5d3e78fc44748 --- M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinklistview.css M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css M repo/resources/templates.php 4 files changed, 43 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/11/179911/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js index 0eaf996..f2c41bd 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js @@ -104,6 +104,8 @@ // sitelinkview is created dynamically, in contrast to being initialized on pre-existing // DOM. this._draw(); + } else { + this._shortenPageName(); } this._createBadgeSelector(); @@ -189,10 +191,42 @@ this._drawEditMode(); } else { this.element.removeClass( 'wb-edit' ); + this._shortenPageName(); } }, /** +* Shortens the page name using the ellipsis character in order to prevent the page name from +* wrapping. +* @private +*/ + _shortenPageName: function() { + if( this._isInEditMode ) { + return; + } + var $a = this.$link.find( 'a' ), + fullText = $a.text(), + text = fullText; + + $a.text( '.' ); + + var lineHeight = this.element.height(); + + $a.text( text ); + + if( this.element.height() <= lineHeight ) { + return; + } + + while( this.element.height() > lineHeight && text.length > 0 ) { + text = text.substring( 0, text.length - 1 ); + $a.text( text + '…' ); + } + + $a.attr( 'title', fullText ); + }, + + /** * Draws the edit mode context. */ _drawEditMode: function() { diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinklistview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinklistview.css index 2898caf..e0964a6 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinklistview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinklistview.css @@ -19,10 +19,11 @@ .wikibase-sitelinklistview .wikibase-sitelinkview { clear: both; float: left; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + line-height: 1.2; width: 100%; +} +.wikibase-sitelinklistview.wb-edit .wikibase-sitelinkview { + white-space: nowrap; } .wikibase-sitelinklistview .wikibase-sitelinkview-new { white-space: normal; @@ -47,7 +48,6 @@ .wikibase-sitelinklistview .wikibase-sitelinkview .wikibase-sitelinkview-link { display: inline; margin-left: 0.4em; - white-space: nowrap; word-wrap: break-word; } .wikibase-sitelinklistview .wikibase-sitelinkview .wikibase-sitelinkview-link-new { diff --git a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css index d918b45..1ab169b 100644 --- a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css +++ b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.sitelinkview.css @@ -35,3 +35,7 @@ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; } + +.wikibase-sitelinkview-badges { + margin-left: 0.4em; +} diff --git a/repo/resources/templates.php b/repo/resources/templates.php index 8cbf539..2847641 100644 --- a/repo/resources/templates.php +++ b/repo/resources/templates.php @@ -276,7 +276,7 @@ $templates['wikibase-sitelinkview-pagename'] = <<$2 +$2$3 HTML; $templates['wikibase-sitelinkview-unknown'] = -- To view, visit https://gerrit.wikimedia.org/r/179911 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2439aeda32c281bceb6ffdad80b5d3e78fc44748 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: H
[MediaWiki-commits] [Gerrit] Removed visible white space from sitelinkview template - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179910 Change subject: Removed visible white space from sitelinkview template .. Removed visible white space from sitelinkview template Change-Id: Ie1406ea4dc9a532b9c7a911169b9da9df852fbe3 --- M repo/resources/templates.php 1 file changed, 1 insertion(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/10/179910/1 diff --git a/repo/resources/templates.php b/repo/resources/templates.php index 442d5e2..8cbf539 100644 --- a/repo/resources/templates.php +++ b/repo/resources/templates.php @@ -270,8 +270,7 @@ $4 - - $6 + $6 HTML; -- To view, visit https://gerrit.wikimedia.org/r/179910 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie1406ea4dc9a532b9c7a911169b9da9df852fbe3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Prevent focusing disabled toolbar buttons - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179467 Change subject: Prevent focusing disabled toolbar buttons .. Prevent focusing disabled toolbar buttons Change-Id: Iada2b49530833c26493e22e41cdc465622a00e70 --- M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarbutton.js 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/67/179467/1 diff --git a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarbutton.js b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarbutton.js index 76e43e3..3666e9e 100644 --- a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarbutton.js +++ b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarbutton.js @@ -85,6 +85,12 @@ .removeClass( 'wikibase-toolbar-button-' + this.options.cssClassSuffix ); } this.element.addClass( 'wikibase-toolbar-button-' + value ); + } else if( key === 'disabled' ) { + if( value ) { + this.$link.attr( 'tabIndex', '-1' ); + } else { + this.$link.removeAttr( 'tabIndex' ); + } } return PARENT.prototype._setOption.apply( this, arguments ); }, -- To view, visit https://gerrit.wikimedia.org/r/179467 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iada2b49530833c26493e22e41cdc465622a00e70 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Have statementview inherit from EditableTemplatedWidget - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179458 Change subject: Have statementview inherit from EditableTemplatedWidget .. Have statementview inherit from EditableTemplatedWidget Standardizing statementview widget. Change-Id: I5af6e89fdad2da193dd13cea1ab7338d3ff83b87 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/addtoolbar/referenceview-snakview.js M lib/resources/jquery.wikibase/toolbar/controller/definitions/removetoolbar/referenceview-snakview.js 3 files changed, 88 insertions(+), 124 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/58/179458/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index 499ff88..1e056fd 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -1,13 +1,13 @@ ( function( mw, wb, $ ) { 'use strict'; - var PARENT = $.ui.TemplatedWidget; + var PARENT = $.ui.EditableTemplatedWidget; /** * View for displaying and editing `wikibase.datamodel.Statement` objects. * @see wikibase.datamodel.Statement * @class jQuery.wikibase.statementview - * @extends jQuery.ui.TemplatedWidget + * @extends jQuery.ui.EditableTemplatedWidget * @uses jQuery.ui.toggler * @uses jQuery.wikibase.listview * @uses jQuery.wikibase.listview.ListItemAdapter @@ -205,28 +205,15 @@ PARENT.prototype._create.call( this ); - this._createRankSelector( this.options.value - ? this.options.value.getRank() - : wb.datamodel.Statement.RANK.NORMAL - ); - this._createMainSnak( this.options.value - ? this.options.value.getClaim().getMainSnak() - : this.options.predefined.mainSnak || null - ); - this._initialQualifiers = this.options.value ? this.options.value.getClaim().getQualifiers() : new wb.datamodel.SnakList(); - // TODO: Allow adding qualifiers when adding a new claim. - if( this.options.value && this._initialQualifiers.length ) { - this._createQualifiersListview( this._initialQualifiers ); - } - this._referencesChanger = this.options.entityChangersFactory.getReferencesChanger(); - this._createReferences( this.options.value ); this._updateHelpMessage(); + + this.draw(); }, /** @@ -236,6 +223,10 @@ * @param {number} rank */ _createRankSelector: function( rank ) { + if( this._rankSelector ) { + return; + } + var $rankSelector = this.$rankSelector.children().first(); this._rankSelector = new $.wikibase.statementview.RankSelector( { value: rank, @@ -260,6 +251,10 @@ * @param {wikibase.datamodel.Snak|null} [snak=null] */ _createMainSnak: function( snak ) { + if( this.$mainSnak.data( 'snakview' ) ) { + return; + } + var self = this; snak = snak || null; @@ -295,6 +290,10 @@ * @param {wikibase.datamodel.SnakList|null} [qualifiers=null] */ _createQualifiersListview: function( qualifiers ) { + if( this._qualifiers ) { + return; + } + var self = this, groupedQualifierSnaks = null; @@ -375,6 +374,8 @@ var $listview = this.$references.children(); if( !$listview.length ) { $listview = $( '' ).prependTo( this.$references ); + } else if( $listview.data( 'listview' ) ) { + return; } $listview.listview( { @@ -383,7 +384,7 @@ newItemOptionsFn: function( value ) { return { value: value || null, - statementGuid: self.value().getClaim().getGuid(), + statementGuid: self.options.value.getClaim().getGuid(), dataTypeStore: self.options.dataTypeStore, entityStore: self.options.entityStore, valueViewBuilder: self.options.valueViewBuilder, @@ -512,6 +513,30 @@ },
[MediaWiki-commits] [Gerrit] statementview: Removed _statement variable - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179422 Change subject: statementview: Removed _statement variable .. statementview: Removed _statement variable - _statement was redundant to options.value. - As to our common pattern, value() now returns current value instead of original/stored value. Change-Id: If0cb699ec36f06177322ba313f2dfae853f06037 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 1 file changed, 42 insertions(+), 40 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/22/179422/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js index 6c47026..499ff88 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js @@ -31,7 +31,8 @@ * * @param {Object} options * @param {wikibase.datamodel.Statement|null} [options.value=null] - *The `Statement` displayed by the view. May be set initially only. + *The `Statement` displayed by the view. May be set initially only and gets updated + *automatically if changes to the `Statement` are saved. *If `null`, the view will be switched to edit mode initially. * @param {wikibase.entityChangers.ClaimsChanger} options.claimsChanger *Required to store the view's `Statement`. @@ -108,7 +109,7 @@ template: 'wikibase-statementview', templateParams: [ function() { // GUID - return ( this._statement && this._statement.getClaim().getGuid() ) || 'new'; + return ( this.options.value && this.options.value.getClaim().getGuid() ) || 'new'; }, function() { // Rank selector return $( '' ); @@ -162,14 +163,6 @@ _referencesListview: null, /** -* The `Statement` represented by this view. This is the `Statement` actually stored in the data -* base. Updates to the `Statement` not yet stored are not reflected in this object. -* @property {wikibase.datamodel.Statement|null} -* @private -*/ - _statement: null, - - /** * Reference to the `listview` widget managing the qualifier `snaklistview`s. * @property {jQuery.wikibase.listview} * @private @@ -212,28 +205,26 @@ PARENT.prototype._create.call( this ); - this._statement = this.options.value; - - this._createRankSelector( this._statement - ? this._statement.getRank() + this._createRankSelector( this.options.value + ? this.options.value.getRank() : wb.datamodel.Statement.RANK.NORMAL ); - this._createMainSnak( this._statement - ? this._statement.getClaim().getMainSnak() - : this.option( 'predefined' ).mainSnak || null + this._createMainSnak( this.options.value + ? this.options.value.getClaim().getMainSnak() + : this.options.predefined.mainSnak || null ); - this._initialQualifiers = this._statement - ? this._statement.getClaim().getQualifiers() + this._initialQualifiers = this.options.value + ? this.options.value.getClaim().getQualifiers() : new wb.datamodel.SnakList(); // TODO: Allow adding qualifiers when adding a new claim. - if( this._statement && this._initialQualifiers.length ) { + if( this.options.value && this._initialQualifiers.length ) { this._createQualifiersListview( this._initialQualifiers ); } this._referencesChanger = this.options.entityChangersFactory.getReferencesChanger(); - this._createReferences( this._statement ); + this._createReferences( this.options.value ); this._updateHelpMessage(); }, @@ -464,12 +455,12 @@ * @private */ _updateHelpMessage: function() { - if( !this._statement && !this.options.predefined.mainSnak ) { + if( !this.options.value && !this.options.predefined.mainSnak ) { return; } - var property = this._statement - ? this._statement.getClaim().getMainSnak().getPropertyId() + var property = this.options.value + ? this.options.value.getClaim().getMainSnak().getPropertyId() : this.options.
[MediaWiki-commits] [Gerrit] Updated RankSelector code documentation - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179138 Change subject: Updated RankSelector code documentation .. Updated RankSelector code documentation Change-Id: Ie7427145da47452597decf0ca213023e1077d661 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js 1 file changed, 44 insertions(+), 38 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/38/179138/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js index 206a8ab..a17b873 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js @@ -1,33 +1,36 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < mediaw...@snater.com > - */ ( function( mw, wb, $, util ) { 'use strict'; var PARENT = $.ui.EditableTemplatedWidget; /** -* The node of the rank selector menu to select a rank from. -* @type {jQuery} +* The node of the `RankSelector` menu to select a `RANK` from. +* @property {jQuery|null} [$menu=null] +* @ignore */ var $menu = null; /** -* Selector for choosing a statement rank. +* Selector for choosing a `Statement` rank. +* @see wikibase.datamodel.Statement.RANK +* @class jQuery.wikibase.statementview.RankSelector +* @extends jQuery.ui.EditableTemplatedWidget * @since 0.5 -* @extends jQuery.ui.TemplatedWidget +* @licence GNU GPL v2+ +* @author H. Snater < mediaw...@snater.com > * -* @option [value] {boolean} The rank that shall be selected. -* Default: wb.datamodel.Statement.RANK.NORMAL +* @constructor * -* @option [isRTL] {boolean} Defines whether the widget is displayed in right-to-left context. -* If not specified, the context is detected by checking whether the 'rtl' css class is -* set on the HTML body element. -* Default: false -* -* @event afterchange Triggered after the snak type got changed -*(1) {jQuery.Event} +* @param {Object} [options] +* @param {number} [options.value=wikibase.datamodel.Statement.RANK.NORMAL] +*The `RANK` that shall be selected. +* @param {boolean} [options.isRTL=false] +*Whether the widget is displayed in right-to-left context. +*/ + /** +* @event afterchange +* Triggered after the snak type got changed. +* @param {jQuery.Event} event */ $.wikibase.statementview.RankSelector = util.inherit( PARENT, { namespace: 'wikibase', @@ -35,7 +38,9 @@ widgetFullName: 'wikibase-rankselector', /** -* @type {Object} +* @inheritdoc +* @protected +* @readonly */ options: { template: 'wikibase-rankselector', @@ -44,24 +49,22 @@ '', '' ], - templateShortCuts: { '$icon': '.ui-icon-rankselector' }, - value: wb.datamodel.Statement.RANK.NORMAL, isRtl: false }, /** -* The rank currently featured by the rank selector. -* @see wb.datamodel.Statement.RANK +* The `RANK` currently featured by the `RankSelector`. +* @see wikibase.datamodel.Statement.RANK * @type {number} */ _rank: null, /** -* @see jQuery.Widget._create +* @inheritdoc */ _create: function() { var self = this; @@ -124,7 +127,7 @@ }, /** -* @see jQuery.Widget.destroy +* @inheritdoc */ destroy: function() { if( $( '.' + this.widgetFullName ).length === 0 ) { @@ -142,8 +145,8 @@ }, /** -* @see jQuery.Widget._setOption -* @triggers afterchange +* @inheritdoc +* @protected */ _setOption: function( key, value ) { var response = PARENT.prototype._setOption.apply( this, arguments ); @@ -157,14 +160,16 @@ }, /** -
[MediaWiki-commits] [Gerrit] Consolidated RankSelector widget - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/179136 Change subject: Consolidated RankSelector widget .. Consolidated RankSelector widget - Have RankSelector inherit from EditableTemplatedWidget. - Properly overwrite necessary jQuery.Widget members. - Make use of jQuery.Widget native functionality (disable/enable). - Removed RankSelector specific code from statementview. Requires adjusting browser test selectors. Change-Id: I355e1e59f538aa2bfffd0dccd5e96e457dd8fce2 --- M lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js M lib/resources/jquery.wikibase/resources.php M lib/resources/jquery.wikibase/themes/default/jquery.wikibase.statementview.RankSelector.css M lib/tests/qunit/jquery.wikibase/jquery.wikibase.statementview.RankSelector.tests.js M repo/includes/View/ClaimHtmlGenerator.php M repo/resources/templates.php 7 files changed, 128 insertions(+), 147 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/36/179136/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js index 0e5068d..0fa4d27 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.RankSelector.js @@ -5,7 +5,7 @@ ( function( mw, wb, $, util ) { 'use strict'; - var PARENT = $.ui.TemplatedWidget; + var PARENT = $.ui.EditableTemplatedWidget; /** * The node of the rank selector menu to select a rank from. @@ -18,7 +18,7 @@ * @since 0.5 * @extends jQuery.ui.TemplatedWidget * -* @option [rank] {boolean} The rank that shall be selected. +* @option [value] {boolean} The rank that shall be selected. * Default: wb.datamodel.Statement.RANK.NORMAL * * @option [isRTL] {boolean} Defines whether the widget is displayed in right-to-left context. @@ -30,14 +30,15 @@ *(1) {jQuery.Event} */ $.wikibase.statementview.RankSelector = util.inherit( PARENT, { - widgetName: 'wikibase-rankselector', - widgetBaseClass: 'wb-rankselector', + namespace: 'wikibase', + widgetName: 'rankselector', + widgetFullName: 'wikibase-rankselector', /** * @type {Object} */ options: { - template: 'wb-rankselector', + template: 'wikibase-rankselector', templateParams: [ '', '', @@ -48,7 +49,7 @@ '$icon': '.ui-icon-rankselector' }, - rank: wb.datamodel.Statement.RANK.NORMAL, + value: wb.datamodel.Statement.RANK.NORMAL, isRtl: undefined }, @@ -75,25 +76,25 @@ rank = $li.data( self.widgetName + '-menuitem-rank' ); if( rank !== undefined ) { - $.data( this, self.widgetName ).rank( rank ); + $.data( this, self.widgetName ).value( rank ); } } ); } this.element - .addClass( this.widgetBaseClass ) + .addClass( this.widgetFullName ) .on( 'mouseover.' + this.widgetName, function( event ) { - if( !self.isDisabled() ) { + if( !self.option( 'disabled' ) && self.isInEditMode() ) { self.element.addClass( 'ui-state-hover' ); } } ) .on( 'mouseout.' + this.widgetName, function( event ) { - if( !self.isDisabled() ) { + if( !self.option( 'disabled' ) && self.isInEditMode() ) { self.element.removeClass( 'ui-state-hover' ); } } ) .on( 'click.' + this.widgetName, function( event ) { - if( self.isDisabled() || $menu.is( ':visible' ) ) { + if( self.option( 'disabled' ) || !self.isInEditMode() || $menu.is( ':visible' ) ) { $menu.hide();