Daniel Werner has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/67303


Change subject: Fixed assumption of SiteLinksEditTool of single edit tool per 
page (DO NOT MERGE)
......................................................................

Fixed assumption of SiteLinksEditTool of single edit tool per page (DO NOT 
MERGE)

TODO: This somehow breaks the table sorter when having multiple instances of 
the SiteLinksEditTool.

Change-Id: Ie516fbdae1dad32dee44f775025828f07c6f80cb
---
M lib/resources/wikibase.ui.SiteLinksEditTool.js
1 file changed, 14 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/03/67303/1

diff --git a/lib/resources/wikibase.ui.SiteLinksEditTool.js 
b/lib/resources/wikibase.ui.SiteLinksEditTool.js
index a8ee96c..1b291ec 100644
--- a/lib/resources/wikibase.ui.SiteLinksEditTool.js
+++ b/lib/resources/wikibase.ui.SiteLinksEditTool.js
@@ -64,7 +64,8 @@
 
                if ( $( 'table.wb-sitelinks thead' ).children().length > 0 ) {
                        // initially sort on the site id column
-                       $( 'table.wb-sitelinks' ).tablesorter( { sortList: 
[{1:'asc'}] } );
+                       // TODO: re-activate after fixing tablesorter bug 
appearing with multiple instances
+                       //$( 'table.wb-sitelinks' ).tablesorter( { sortList: 
[{1:'asc'}] } );
                }
 
        },
@@ -87,7 +88,7 @@
         * @return jQuery
         */
        _getToolbarParent: function() {
-               return $( 'tfoot .wb-editsection' );
+               return this._subject.children( 'tfoot' ).find( 
'.wb-editsection' );
        },
 
        /**
@@ -130,12 +131,14 @@
         * @return {wb.ui.PropertyEditTool.EditableValue}
         */
        enterNewValue: function( value ) {
+               var $siteLinksTable = this._subject;
+
                // Attach the headers before initializing the new value in 
order to not have the license
                // information tooltip appear in the wrong spot. (The new 
value's table row would be shifted
                // after adding the headers.)
                if ( this._editableValues.length === 0 ) {
                        // This would be the first site link -> attach column 
headers.
-                       $( 'table.wb-sitelinks thead' ).append(
+                       $siteLinksTable.children( 'thead' ).append(
                                mw.template( 'wb-sitelinks-thead',
                                        mw.message( 
'wikibase-sitelinks-sitename-columnheading' ).escaped(),
                                        mw.message( 
'wikibase-sitelinks-siteid-columnheading' ).escaped(),
@@ -151,17 +154,19 @@
                $( newValue ).on( 'afterStopEditing', function( event, save, 
wasPending ) {
                        if ( save ) {
                                // move appended site link into the table body 
to have it included in sorting
-                               $( 'table.wb-sitelinks tfoot 
.wb-ui-propertyedittool-editablevalue' )
+                               $siteLinksTable
+                               .children( 'tfoot 
.wb-ui-propertyedittool-editablevalue' )
                                .appendTo( 'table.wb-sitelinks tbody' );
 
                                // init tablesorter if it has not been 
initialised yet (no site link existed
                                // previous to adding the just added site link)
-                               if ( $( 'table.wb-sitelinks' ).data( 
'tablesorter' ) === undefined ) {
-                                       $( 'table.wb-sitelinks' ).tablesorter();
+                               if ( $siteLinksTable.data( 'tablesorter' ) === 
undefined ) {
+                                       // TODO: re-activate after fixing 
tablesorter bug appearing with multiple instances
+                                       //$siteLinksTable.tablesorter();
                                } else {
                                        // reset sorting having the sort order 
appear undefined when appending a new
                                        // site link to the bottom of the table
-                                       $( 'table.wb-sitelinks' ).data( 
'tablesorter' ).sort( [] );
+                                       $siteLinksTable.data( 'tablesorter' 
).sort( [] );
                                }
                        }
                } );
@@ -281,10 +286,10 @@
                // no more site links
                if ( this._editableValues.length === 0 ) {
                        // remove column headers
-                       $( 'table.wb-sitelinks thead' ).children( 'tr' 
).last().remove();
+                       this._subject.children( 'thead' ).children( 'tr' 
).last().remove();
 
                        // destroy tablesorter
-                       $( 'table.wb-sitelinks' ).removeData( 'tablesorter' );
+                       this._subject.removeData( 'tablesorter' );
                }
        },
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie516fbdae1dad32dee44f775025828f07c6f80cb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>

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

Reply via email to