Adrian Heine has uploaded a new change for review.
https://gerrit.wikimedia.org/r/297362
Change subject: Remove moving features from JS
......................................................................
Remove moving features from JS
Change-Id: If24fd8e359739e5f9e4fc796ff9ebb12e55cc1b0
---
M view/resources/jquery/wikibase/jquery.wikibase.listview.js
M view/resources/jquery/wikibase/jquery.wikibase.referenceview.js
M view/resources/jquery/wikibase/jquery.wikibase.snaklistview.js
M view/resources/jquery/wikibase/jquery.wikibase.statementview.js
M view/resources/jquery/wikibase/toolbar/controller/resources.php
D view/resources/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.js
M view/resources/jquery/wikibase/toolbar/resources.php
D
view/resources/jquery/wikibase/toolbar/themes/default/jquery.wikibase.movetoolbar.css
M view/tests/qunit/jquery/wikibase/jquery.wikibase.listview.tests.js
M view/tests/qunit/jquery/wikibase/jquery.wikibase.snaklistview.tests.js
D view/tests/qunit/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.tests.js
M view/tests/qunit/jquery/wikibase/toolbar/resources.php
12 files changed, 1 insertion(+), 682 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/62/297362/1
diff --git a/view/resources/jquery/wikibase/jquery.wikibase.listview.js
b/view/resources/jquery/wikibase/jquery.wikibase.listview.js
index 217ed31..3abad34 100644
--- a/view/resources/jquery/wikibase/jquery.wikibase.listview.js
+++ b/view/resources/jquery/wikibase/jquery.wikibase.listview.js
@@ -45,13 +45,6 @@
* @param {jQuery} $li The DOM node pending to be added permanently to the
list.
*/
/**
- * @event afteritemmove
- * Triggered when an item node is moved within the list.
- * @param {jQuery.Event} event
- * @param {number} The item node's new index.
- * @param {number} Number of items in the list.
- */
-/**
* @event destroy
* Triggered when the widget has been destroyed.
* @param {jQuery.Event} event
@@ -239,58 +232,6 @@
}
return -1;
- },
-
- /**
- * Moves a list item to a new index.
- *
- * @param {jQuery} $itemNode
- * @param {number} toIndex
- */
- move: function( $itemNode, toIndex ) {
- var currIndex = this.indexOf( $itemNode ),
- items = this.items();
-
- // No need to move if the item has the index already or if it
should be moved to after the
- // last item although it is at the end already:
- if ( currIndex < 0
- || currIndex === toIndex
- || currIndex === items.length - 1 && toIndex >=
items.length
- ) {
- return;
- }
-
- if ( toIndex >= items.length ) {
- $itemNode.insertAfter( items.last() );
- } else if ( items.eq( toIndex ).prev().get( 0 ) ===
$itemNode.get( 0 ) ) {
- // Item already is at the position it shall be moved to.
- return;
- } else {
- $itemNode.insertBefore( items.eq( toIndex ) );
- }
-
- this._trigger( 'afteritemmove', null, [ this.indexOf( $itemNode
), items.length ] );
- },
-
- /**
- * Moves an item node one index towards the top of the list.
- *
- * @param {jQuery} $itemNode
- */
- moveUp: function( $itemNode ) {
- if ( this.indexOf( $itemNode ) !== 0 ) {
- this.move( $itemNode, this.indexOf( $itemNode ) - 1 );
- }
- },
-
- /**
- * Moves an item node one index towards the bottom of the list.
- *
- * @param {jQuery} $itemNode
- */
- moveDown: function( $itemNode ) {
- // Adding 2 to the index to move the element to before the
element after the next element:
- this.move( $itemNode, this.indexOf( $itemNode ) + 2 );
},
/**
diff --git a/view/resources/jquery/wikibase/jquery.wikibase.referenceview.js
b/view/resources/jquery/wikibase/jquery.wikibase.referenceview.js
index a8a33d2..342af67 100644
--- a/view/resources/jquery/wikibase/jquery.wikibase.referenceview.js
+++ b/view/resources/jquery/wikibase/jquery.wikibase.referenceview.js
@@ -111,7 +111,6 @@
var changeEvents = [
'snakviewchange.' + this.widgetName,
lia.prefixedEvent( 'change.' + this.widgetName ),
- 'listviewafteritemmove.' + this.widgetName,
'listviewitemadded.' + this.widgetName,
'listviewitemremoved.' + this.widgetName
];
@@ -149,7 +148,6 @@
var lia = this.$listview.data( 'listview' ).listItemAdapter(),
events = [
'snakviewchange.' + this.widgetName,
- 'listviewafteritemmove.' + this.widgetName,
'listviewitemadded.' + this.widgetName,
'listviewitemremoved.' + this.widgetName,
lia.prefixedEvent( 'change.' + this.widgetName
),
diff --git a/view/resources/jquery/wikibase/jquery.wikibase.snaklistview.js
b/view/resources/jquery/wikibase/jquery.wikibase.snaklistview.js
index 2599cec..a957de1 100644
--- a/view/resources/jquery/wikibase/jquery.wikibase.snaklistview.js
+++ b/view/resources/jquery/wikibase/jquery.wikibase.snaklistview.js
@@ -145,7 +145,6 @@
this.$listview
.off( '.' + this.widgetName )
.on( this._lia.prefixedEvent( 'change.' ) + this.widgetName
- + ' listviewafteritemmove.' + this.widgetName
+ ' listviewitemremoved.' + this.widgetName, function(
event ) {
// Forward the "change" event to external
components (e.g. the edit toolbar).
self._trigger( 'change' );
@@ -382,89 +381,6 @@
} else {
this.element.focus();
}
- },
-
- /**
- * Moves a `Snak`'s `snakview` within the `snaklistview`. Instead of a
`Snak` and an index, a
- * reordered `SnakList` may be provided.
- *
- * @param {wikibase.datamodel.Snak|wikibase.datamodel.SnakList} snak
- * @param {number} [toIndex]
- */
- move: function( snak, toIndex ) {
- var self = this,
- snakList;
-
- if ( snak instanceof wb.datamodel.Snak ) {
- snakList = this.value();
- if ( snakList ) {
- snakList.move( snak, toIndex );
- }
- } else if ( snak instanceof wb.datamodel.SnakList ) {
- snakList = snak;
- }
-
- if ( snakList ) {
- // Reflect new snak list order in snaklistview:
- snakList.each( function( i, snak ) {
- var $listItem = self._findListItem( snak );
- if ( $listItem ) {
- self._listview.move(
self._findListItem( snak ), i );
- }
- } );
- this._updatePropertyLabels();
- }
- },
-
- /**
- * Moves a `Snak`'s `snakview` towards the top of the `snaklistview` by
one step.
- *
- * @param {wikibase.datamodel.Snak} snak
- */
- moveUp: function( snak ) {
- var snakList = this.value();
-
- if ( snakList ) {
- this.move( snakList.moveUp( snak ) );
- }
- },
-
- /**
- * Moves a `Snak`'s `snakview` towards the bottom of the `snaklistview`
by one step.
- *
- * @param {wikibase.datamodel.Snak} snak
- */
- moveDown: function( snak ) {
- var snakList = this.value();
-
- if ( snakList ) {
- this.move( snakList.moveDown( snak ) );
- }
- },
-
- /**
- * Finds a `Snak`'s `snakview` node within the `snaklistview`'s
`listview` widget.
- *
- * @private
- *
- * @param {wikibase.datamodel.Snak} snak
- * @return {jQuery|null}
- */
- _findListItem: function( snak ) {
- var lia = this._lia,
- $snakview = null;
-
- this._listview.items().each( function() {
- var $itemNode = $( this );
-
- if ( lia.liInstance( $itemNode ).snak().equals( snak )
) {
- $snakview = $itemNode;
- }
-
- return $snakview === null;
- } );
-
- return $snakview;
}
} );
diff --git a/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
b/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
index 848c741..db0755e 100644
--- a/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
+++ b/view/resources/jquery/wikibase/jquery.wikibase.statementview.js
@@ -258,8 +258,7 @@
.on( 'snaklistviewstopediting.' + this.widgetName, function(
event, dropValue ) {
event.stopPropagation();
} )
- .on( 'snaklistviewchange.' + this.widgetName
- + ' listviewafteritemmove.' + this.widgetName,
+ .on( 'snaklistviewchange.' + this.widgetName,
function( event ) {
event.stopPropagation();
self._trigger( 'change' );
diff --git a/view/resources/jquery/wikibase/toolbar/controller/resources.php
b/view/resources/jquery/wikibase/toolbar/controller/resources.php
index a110ebe..8f27832 100644
--- a/view/resources/jquery/wikibase/toolbar/controller/resources.php
+++ b/view/resources/jquery/wikibase/toolbar/controller/resources.php
@@ -170,7 +170,6 @@
'dependencies' => array(
'jquery.wikibase.addtoolbar',
'jquery.wikibase.edittoolbar',
- 'jquery.wikibase.movetoolbar',
'jquery.wikibase.removetoolbar',
),
),
diff --git
a/view/resources/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.js
b/view/resources/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.js
deleted file mode 100644
index 166f0bf..0000000
--- a/view/resources/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * @license GPL-2.0+
- * @author H. Snater < [email protected] >
- */
-( function( mw, $ ) {
- 'use strict';
-
-var PARENT = $.wikibase.toolbar;
-
-/**
- * "Move" toolbar widget.
- * @since 0.4
- * @extends jQuery.wikibase.toolbar
- *
- * This widget offers two buttons to move a referenced object within a list up
or down. With the
- * corresponding toolbar definition being initialized on a parent item, the
movetoolbar itself
- * needs to be initialized on every list item.
- *
- * @event up
- * Triggered when the "move up" button is hit.
- * - {jQuery.Event}
- *
- * @event down
- * Triggered when the "move down" button is hit.
- * - {jQuery.Event}
- */
-$.widget( 'wikibase.movetoolbar', PARENT, {
- /**
- * @type {Object}
- */
- _buttons: null,
-
- /**
- * @see jQuery.wikibase.toolbar._create
- */
- _create: function() {
- PARENT.prototype._create.call( this );
-
- this._buttons = {};
-
- if ( !this.options.$content.length ) {
- this.options.$content
- = this._createDefaultButton( 'up' ).add(
this._createDefaultButton( 'down' ) )
- .appendTo( this.getContainer() );
- this.draw();
- }
- },
-
- /**
- * @param {string} direction "up"|"down"
- * @return {jQuery}
- */
- _createDefaultButton: function( direction ) {
- var self = this;
-
- this._buttons[direction] = $( '<span/>' ).toolbarbutton( {
- $label: $( '<span/>', {
- title: mw.msg( 'wikibase-move-' + direction ),
- 'class': 'ui-icon '
- + ( direction === 'up' ?
'ui-icon-triangle-1-n' : 'ui-icon-triangle-1-s' )
- } ),
- cssClassSuffix: 'move'
- } )
- .on( 'toolbarbuttonaction.' + this.widgetName, function() {
- self._trigger( direction );
- } );
-
- return this._buttons[direction];
- },
-
- /**
- * Returns a button by its name creating the button if it has not yet
been created.
- *
- * @param {string} buttonName "up"|"down"
- * @return {jQuery.wikibase.toolbarbutton}
- */
- getButton: function( buttonName ) {
- return this._buttons[buttonName].data( 'toolbarbutton' );
- },
-
- /**
- * @see jQuery.wikibase.toolbar.focus
- */
- focus: function() {
- var buttonUp = this._buttons.up && this._buttons.up.data(
'toolbarbutton' ),
- buttonDown = this._buttons.down &&
this._buttons.down.data( 'toolbarbutton' );
-
- if ( buttonUp && !buttonUp.option( 'disabled' ) ) {
- buttonUp.focus();
- } else if ( buttonDown && !buttonDown.option( 'disabled' ) ) {
- buttonDown.focus();
- } else {
- this.element.focus();
- }
- }
-} );
-
-}( mediaWiki, jQuery ) );
diff --git a/view/resources/jquery/wikibase/toolbar/resources.php
b/view/resources/jquery/wikibase/toolbar/resources.php
index 2c7a62a..306d51a 100644
--- a/view/resources/jquery/wikibase/toolbar/resources.php
+++ b/view/resources/jquery/wikibase/toolbar/resources.php
@@ -51,23 +51,6 @@
),
),
- 'jquery.wikibase.movetoolbar' => $moduleTemplate + array(
- 'scripts' => array(
- 'jquery.wikibase.movetoolbar.js',
- ),
- 'styles' => array(
-
'themes/default/jquery.wikibase.movetoolbar.css',
- ),
- 'dependencies' => array(
- 'jquery.wikibase.toolbar',
- 'jquery.wikibase.toolbarbutton',
- ),
- 'messages' => array(
- 'wikibase-move-up',
- 'wikibase-move-down',
- ),
- ),
-
'jquery.wikibase.removetoolbar' => $moduleTemplate + array(
'scripts' => array(
'jquery.wikibase.removetoolbar.js',
diff --git
a/view/resources/jquery/wikibase/toolbar/themes/default/jquery.wikibase.movetoolbar.css
b/view/resources/jquery/wikibase/toolbar/themes/default/jquery.wikibase.movetoolbar.css
deleted file mode 100644
index 824b799..0000000
---
a/view/resources/jquery/wikibase/toolbar/themes/default/jquery.wikibase.movetoolbar.css
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * @license GNU GPL v2+
- * @author H. Snater < [email protected] >
- */
-
-.wikibase-movetoolbar-container > * {
- float: left;
-}
-
-.wikibase-movetoolbar-container .ui-icon {
- width: 8px;
-}
-
-.wikibase-movetoolbar-container .ui-icon-triangle-1-n {
- background-position: -4px -16px;
-}
-
-.wikibase-movetoolbar-container .ui-icon-triangle-1-s {
- background-position: -68px -16px;
-}
diff --git a/view/tests/qunit/jquery/wikibase/jquery.wikibase.listview.tests.js
b/view/tests/qunit/jquery/wikibase/jquery.wikibase.listview.tests.js
index cd0b8cb..3f910fc 100644
--- a/view/tests/qunit/jquery/wikibase/jquery.wikibase.listview.tests.js
+++ b/view/tests/qunit/jquery/wikibase/jquery.wikibase.listview.tests.js
@@ -337,119 +337,6 @@
}
} );
- QUnit.test( 'move()', 56, function( assert ) {
- var values = ['a', 'b', 'c', 'd'],
- $node,
- listview;
-
- /**
- * 0 => Index of item to move
- * 1 => Index to move item to
- * 2 => Expected resulting order
- * @type {*[][]}
- */
- var testCases = [
- [0, 0, 'abcd'], // no event
- [0, 1, 'abcd'], // no event
- [0, 2, 'bacd'],
- [0, 3, 'bcad'],
- [0, 4, 'bcda'],
- [1, 0, 'bacd'],
- [1, 1, 'abcd'], // no event
- [1, 2, 'abcd'], // no event
- [1, 3, 'acbd'],
- [1, 4, 'acdb'],
- [2, 0, 'cabd'],
- [2, 1, 'acbd'],
- [2, 2, 'abcd'], // no event
- [2, 3, 'abcd'], // no event
- [2, 4, 'abdc'],
- [3, 0, 'dabc'],
- [3, 1, 'adbc'],
- [3, 2, 'abdc'],
- [3, 3, 'abcd'], // no event
- [3, 4, 'abcd'] // no event
- ];
-
- $.each( testCases, function( i, testCase ) {
- $node = createListview( values );
- listview = $node.data( 'listview' );
-
- $node.one( 'listviewafteritemmove', function( event,
newIndex, listLength ) {
- assert.ok(
- true,
- 'Triggered "afteritemmove" event.'
- );
-
- assert.equal(
- newIndex,
- testCase[2].indexOf(
values[testCase[0]] ),
- 'Verified new item index.'
- );
-
- assert.equal(
- listLength,
- testCase[2].length,
- 'Verified list length.'
- );
- } );
-
- listview.move( listview.items().eq( testCase[0] ),
testCase[1] );
-
- $node.off( 'listviewafteritemmove' );
-
- assert.equal(
- getListItemStrings( listview ),
- testCase[2],
- 'Moving item #' + testCase[0] + ' to index #' +
testCase[1] + ' results in order "'
- + testCase[2] + '".'
- );
- } );
- } );
-
- QUnit.test( 'moveUp() and moveDown()', function( assert ) {
- assert.expect( 8 );
- var values = ['a', 'b', 'c', 'd'];
-
- /**
- * The key specifies the objects method to call. The value
represents the expected resulting
- * order when issuing the method on the item that has the same
index than the result.
- * @type {Object}
- */
- var testCases = {
- moveUp: [
- 'abcd',
- 'bacd',
- 'acbd',
- 'abdc'
- ],
- moveDown: [
- 'bacd',
- 'acbd',
- 'abdc',
- 'abcd'
- ]
- };
-
- var $node, listview;
-
- $.each( testCases, function( methodName, expectedResults ) {
- $.each( expectedResults, function( i, expected ) {
- $node = createListview( values );
- listview = $node.data( 'listview' );
-
- listview[methodName]( listview.items().eq( i )
);
-
- assert.equal(
- getListItemStrings( listview ),
- expected,
- 'Issuing ' + methodName + '() on item
#' + i + ' results in order "' + expected
- + '".'
- );
- } );
- } );
- } );
-
QUnit.test( 'reuse items', function( assert ) {
assert.expect( 1 );
var $node = $( document.createElement( 'span' ) );
diff --git
a/view/tests/qunit/jquery/wikibase/jquery.wikibase.snaklistview.tests.js
b/view/tests/qunit/jquery/wikibase/jquery.wikibase.snaklistview.tests.js
index 9a4de8a..dd18af0 100644
--- a/view/tests/qunit/jquery/wikibase/jquery.wikibase.snaklistview.tests.js
+++ b/view/tests/qunit/jquery/wikibase/jquery.wikibase.snaklistview.tests.js
@@ -735,133 +735,6 @@
);
} );
- QUnit.test( 'move()', function( assert ) {
- assert.expect( 31 );
- var snakList = new wb.datamodel.SnakList( snakSet );
-
- /**
- * Array of test case definitions. Test case definition
structure:
- * [0] => Index of element to move
- * [1] => Index where to move element
- * [2] => Expected result when concatenating the string values
of the snak list's snaks.
- * @type {*[][]}
- */
- var testCases = [
- [ 0, 1, 'bacdefg' ],
- [ 0, 5, 'cdeabfg' ],
- [ 0, 6, 'cdefabg' ],
- [ 0, 7, 'cdefgab' ],
- [ 1, 0, 'bacdefg' ],
- [ 1, 5, 'cdeabfg' ],
- [ 1, 6, 'cdefabg' ],
- [ 1, 7, 'cdefgab' ],
- [ 2, 0, 'cdeabfg' ],
- [ 2, 3, 'abdcefg' ],
- [ 2, 4, 'abdecfg' ],
- [ 2, 6, 'abfcdeg' ],
- [ 2, 7, 'abfgcde' ],
- [ 3, 0, 'cdeabfg' ],
- [ 3, 2, 'abdcefg' ],
- [ 3, 4, 'abcedfg' ],
- [ 3, 6, 'abfcdeg' ],
- [ 3, 7, 'abfgcde' ],
- [ 4, 0, 'cdeabfg' ],
- [ 4, 2, 'abecdfg' ],
- [ 4, 3, 'abcedfg' ],
- [ 4, 6, 'abfcdeg' ],
- [ 4, 7, 'abfgcde' ],
- [ 5, 0, 'fabcdeg' ],
- [ 5, 2, 'abfcdeg' ],
- [ 5, 7, 'abcdegf' ],
- [ 6, 0, 'gabcdef' ],
- [ 6, 2, 'abgcdef' ],
- [ 6, 5, 'abcdegf' ]
- ];
-
- var $node,
- snaklistview;
-
- for ( var i = 0; i < testCases.length; i++ ) {
- $node = createSnaklistview( snakList );
- snaklistview = $node.data( 'snaklistview' );
-
- snaklistview.move( snakSet[testCases[i][0]],
testCases[i][1] );
-
- assert.equal(
- snakOrder( snaklistview.value() ),
- testCases[i][2],
- 'Verified moving a snak with test set #' + i +
'.'
- );
- }
-
- $node = createSnaklistview( snakList );
- snaklistview = $node.data( 'snaklistview' );
- snaklistview.move( snakSet[1], 1 );
-
- assert.equal(
- snakOrder( snaklistview.value() ),
- 'abcdefg',
- 'Nothing changed when trying to move a snak to an index
it already has.'
- );
-
- assert.throws(
- function() {
- $node = createSnaklistview( snakList );
- snaklistview = $node.data( 'snaklistview' );
- snaklistview.move( snakSet[0], 4 );
- },
- 'move() throws an error when trying to move a snak to
an invalid index.'
- );
- } );
-
- QUnit.test( 'moveUp() and moveDown()', function( assert ) {
- assert.expect( 14 );
- var snakList = new wb.datamodel.SnakList( snakSet ),
- $node,
- snaklistview;
-
- /**
- * Array of test case definitions for moveUp() and moveDown()
methods. Test case definition
- * structure:
- * [0] => Resulting order after moving the element having the
same index in the snak list up.
- * [1] => Resulting order after moving the element having the
same index in the snak list down.
- * @type {string[][]}
- */
- var testCases = [
- ['abcdefg', 'bacdefg' ],
- ['bacdefg', 'cdeabfg' ],
- ['cdeabfg', 'abdcefg' ],
- ['abdcefg', 'abcedfg' ],
- ['abcedfg', 'abfcdeg' ],
- ['abfcdeg', 'abcdegf' ],
- ['abcdegf', 'abcdefg' ]
- ];
-
- for ( var i = 0; i < testCases.length; i++ ) {
- $node = createSnaklistview( snakList );
- snaklistview = $node.data( 'snaklistview' );
-
- snaklistview.moveUp( snakSet[i] );
-
- assert.equal(
- snakOrder( snaklistview.value() ),
- testCases[i][0],
- 'Moving up a snak with test set #' + i + '.'
- );
-
- $node = createSnaklistview( snakList );
- snaklistview = $node.data( 'snaklistview' );
-
- snaklistview.moveDown( snakSet[i] );
-
- assert.equal(
- snakOrder( snaklistview.value() ),
- testCases[i][1],
- 'Moved down a snak with test set #' + i + '.'
- );
- }
- } );
-
QUnit.test( 'singleProperty option', function( assert ) {
assert.expect( 10 );
var $node = createSnaklistview( snakLists[0], { singleProperty:
true } ),
diff --git
a/view/tests/qunit/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.tests.js
b/view/tests/qunit/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.tests.js
deleted file mode 100644
index d123eef..0000000
---
a/view/tests/qunit/jquery/wikibase/toolbar/jquery.wikibase.movetoolbar.tests.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * @license GPL-2.0+
- * @author H. Snater < [email protected] >
- */
-( function( $, QUnit ) {
- 'use strict';
-
-QUnit.module( 'jquery.wikibase.movetoolbar', QUnit.newMwEnvironment( {
- setup: function() {
- $.widget( 'wikibasetest.valuewidget', {
- value: function( value ) {
- if ( value ) {
- this.options.value = value;
- }
- return this.options.value;
- }
- } );
- },
- teardown: function() {
- $( '.test_listview' ).each( function() {
- var $listview = $( this ),
- listview = $listview.data( 'listview' );
-
- if ( listview ) {
- listview.items().each( function() {
- var $movetoolbar = $( this ),
- movetoolbar =
$movetoolbar.data( 'movetoolbar' );
-
- if ( movetoolbar ) {
- movetoolbar.destroy();
- }
- } );
-
- listview.destroy();
- }
-
- $listview.remove();
- } );
-
- delete( $.wikibasetest.valuewidget );
- }
-} ) );
-
-/**
- * @param {*[]} [value]
- * @return {jQuery}
- */
-function createListview( value ) {
- var $listview = $( '<div/>' ).addClass( 'test_listview' );
-
- $listview.listview( {
- listItemAdapter: new $.wikibase.listview.ListItemAdapter( {
- listItemWidget: $.wikibasetest.valuewidget,
- newItemOptionsFn: function( value ) {
- return { value: value || null };
- }
- } ),
- value: ( value ) ? value : null
- } );
-
- return $listview;
-}
-
-/**
- * @param {*[]} listviewValue
- * @return {jQuery}
- */
-function createListViewWithMovetoolbar( listviewValue ) {
- var $listview = createListview( listviewValue ),
- listview = $listview.data( 'listview' );
-
- listview.items().each( function() {
- $( this ).movetoolbar( { listView: listview } );
- } );
-
- return $listview;
-}
-
-QUnit.test( 'Create & destroy', function( assert ) {
- assert.expect( 6 );
- var items = ['a', 'b', 'c'],
- $listview = createListViewWithMovetoolbar( items ),
- listview = $listview.data( 'listview' ),
- $movetoolbar = listview.items().first(),
- movetoolbar = $movetoolbar.data( 'movetoolbar' );
-
- assert.ok(
- movetoolbar instanceof $.wikibase.movetoolbar,
- 'Initialized widget.'
- );
-
- assert.equal(
- $movetoolbar.children().length,
- 2,
- 'Toolbar features two child nodes.'
- );
-
- assert.equal(
- $movetoolbar.children().first().data( 'toolbarbutton' ),
- movetoolbar.getButton( 'up' ),
- 'First child node is the "move up" button.'
- );
-
- assert.equal(
- $movetoolbar.children().last().data( 'toolbarbutton' ),
- movetoolbar.getButton( 'down' ),
- 'Last child node is the "move down" button.'
- );
-
- movetoolbar.destroy();
-
- assert.ok(
- !$movetoolbar.data( 'toolbar' ),
- 'Destroyed widget.'
- );
-
- assert.strictEqual(
- listview.items().length,
- items.length,
- 'Items in referenced listview widget remain.'
- );
-} );
-
-QUnit.test( 'Button events', 2, function( assert ) {
- var items = ['a', 'b', 'c'],
- $listview = createListViewWithMovetoolbar( items ),
- listview = $listview.data( 'listview' ),
- $movetoolbar = listview.items().first(),
- movetoolbar = $movetoolbar.data( 'movetoolbar' );
-
- $movetoolbar.on( 'movetoolbarup', function( event ) {
- assert.ok(
- true,
- 'Triggered "up" event.'
- );
- } );
-
- $movetoolbar.on( 'movetoolbardown', function( event ) {
- assert.ok(
- true,
- 'Triggered "down" event.'
- );
- } );
-
- movetoolbar.getButton( 'up' ).element.children( 'a' ).trigger( 'click'
);
- movetoolbar.getButton( 'down' ).element.children( 'a' ).trigger(
'click' );
-} );
-
-}( jQuery, QUnit ) );
diff --git a/view/tests/qunit/jquery/wikibase/toolbar/resources.php
b/view/tests/qunit/jquery/wikibase/toolbar/resources.php
index bbb9da6..1985084 100644
--- a/view/tests/qunit/jquery/wikibase/toolbar/resources.php
+++ b/view/tests/qunit/jquery/wikibase/toolbar/resources.php
@@ -35,16 +35,6 @@
),
),
- 'jquery.wikibase.movetoolbar.tests' => $moduleTemplate + array(
- 'scripts' => array(
- 'jquery.wikibase.movetoolbar.tests.js',
- ),
- 'dependencies' => array(
- 'jquery.wikibase.movetoolbar',
- 'jquery.wikibase.listview',
- ),
- ),
-
'jquery.wikibase.removetoolbar.tests' => $moduleTemplate +
array(
'scripts' => array(
'jquery.wikibase.removetoolbar.tests.js',
--
To view, visit https://gerrit.wikimedia.org/r/297362
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If24fd8e359739e5f9e4fc796ff9ebb12e55cc1b0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Heine <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits