jenkins-bot has submitted this change and it was merged.

Change subject: Claimview "movetoolbar" definition refactoring
......................................................................


Claimview "movetoolbar" definition refactoring

Change-Id: I5670cdd26c0b870410c25f95f09fb6886654ee65
---
M lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
1 file changed, 9 insertions(+), 20 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  Daniel Werner: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
index 5d9aad2..050174b 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
@@ -871,38 +871,27 @@
                        // initialized on:
                        $snaklistviewNode.closest( '.wb-claim-qualifiers' 
).off( '.movetoolbar' );
                },
-               'movetoolbarup': function( event ) {
+               'movetoolbarup movetoolbardown': function( event ) {
                        var $snakview = $( event.target ),
                                snak = $snakview.data( 'wikibaseSnakview' 
).snak(),
                                $snaklistview = $snakview.closest( 
':wikibase-snaklistview' ),
                                snaklistview = $snaklistview.data( 
'snaklistview' ),
                                snakList = snaklistview.value(),
                                $listview = $snaklistview.closest( 
':wikibase-listview' ),
-                               listview = $listview.data( 'listview' );
+                               listview = $listview.data( 'listview' ),
+                               action = ( event.type === 'movetoolbarup' ) ? 
'moveUp' : 'moveDown';
 
-                       if( snakList.indexOf( snak ) !== 0 ) {
+                       if( action === 'moveUp' && snakList.indexOf( snak ) !== 
0 ) {
                                // Snak is not in top of the snaklistview group 
the snaks featuring the same
                                // property. Therefore, the snak is to be moved 
within the snaklistview.
                                snaklistview.moveUp( snak );
-                       } else {
-                               // Moving the topmost snak of a snaklistview up 
involves moving the whole
-                               // snaklistview within the parent listview.
-                               listview.moveUp( $snaklistview );
-                       }
-               },
-               'movetoolbardown': function( event ) {
-                       var $snakview = $( event.target ),
-                               snak = $snakview.data( 'wikibaseSnakview' 
).snak(),
-                               $snaklistview = $snakview.closest( 
':wikibase-snaklistview' ),
-                               snaklistview = $snaklistview.data( 
'snaklistview' ),
-                               snakList = snaklistview.value(),
-                               $listview = $snaklistview.closest( 
':wikibase-listview' ),
-                               listview = $listview.data( 'listview' );
-
-                       if( snakList.indexOf( snak ) !== snakList.length - 1 ) {
+                       } else if( action === 'moveDown' && snakList.indexOf( 
snak ) !== snakList.length - 1 ) {
+                               // Move down snakview within a snaklistview.
                                snaklistview.moveDown( snak );
                        } else {
-                               listview.moveDown( $snaklistview );
+                               // When issuing "move up" on a snak on top of a 
snak list, the whole snaklistview
+                               // has to be move; Same for "move down" on a 
snak at the bottom of a snak list.
+                               listview[action]( $snaklistview );
                        }
                },
                'movetoolbarup movetoolbardown listviewitemadded 
listviewitemremoved': function( event ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/85670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5670cdd26c0b870410c25f95f09fb6886654ee65
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to