Henning Snater has uploaded a new change for review.

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


Change subject: Removed toolbarlabel's set/removeFocus
......................................................................

Removed toolbarlabel's set/removeFocus

toolbarlabel's set/removeFocus methods have become obsolete after converting 
the toolbar label
to a widget and after no more DOM replacing is being performed when changing a 
button's state.

Change-Id: Ibdca1cbd03e25e5b5878f4290fc40d2f3d25dc31
---
M lib/resources/jquery.wikibase/toolbar/addtoolbar.js
M lib/resources/jquery.wikibase/toolbar/edittoolbar.js
M lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
M lib/resources/jquery.wikibase/toolbar/toolbarlabel.js
M lib/resources/wikibase.ui.PropertyEditTool.js
M lib/tests/qunit/jquery.wikibase/toolbar/toolbarbutton.tests.js
M lib/tests/qunit/jquery.wikibase/toolbar/toolbarlabel.tests.js
7 files changed, 8 insertions(+), 85 deletions(-)


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

diff --git a/lib/resources/jquery.wikibase/toolbar/addtoolbar.js 
b/lib/resources/jquery.wikibase/toolbar/addtoolbar.js
index 8c2c3dc..4691bd6 100644
--- a/lib/resources/jquery.wikibase/toolbar/addtoolbar.js
+++ b/lib/resources/jquery.wikibase/toolbar/addtoolbar.js
@@ -134,7 +134,7 @@
                                                $node.trigger( event.type );
                                        } else {
                                                
event.stopImmediatePropagation();
-                                               self.toolbar.$btnAdd.data( 
'toolbarbutton' ).setFocus();
+                                               self.toolbar.$btnAdd.focus();
                                        }
                                }
                        );
diff --git a/lib/resources/jquery.wikibase/toolbar/edittoolbar.js 
b/lib/resources/jquery.wikibase/toolbar/edittoolbar.js
index e293707..187ec05 100644
--- a/lib/resources/jquery.wikibase/toolbar/edittoolbar.js
+++ b/lib/resources/jquery.wikibase/toolbar/edittoolbar.js
@@ -172,7 +172,7 @@
                                editGroup.toNonEditMode();
                                self.enable();
                                self.toggleActionMessage( function() {
-                                       editGroup.$btnEdit.data( 
'toolbarbutton' ).setFocus();
+                                       editGroup.$btnEdit.focus();
                                } );
                        } )
                        .on( prefix + 'afterstartediting ' + prefix + 'change', 
function( event ) {
diff --git a/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js 
b/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
index 486a2ba..94ecb30 100644
--- a/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
+++ b/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
@@ -78,13 +78,6 @@
                        $( wb ).off( 'restrictEntityPageActions.' + 
this.widgetName
                                + 'blockEntityPageActions.' + this.widgetName );
                }
-       },
-
-       /**
-        * @see jQuery.wikibase.toolbarlabel.setFocus
-        */
-       setFocus: function() {
-               this.element.focus();
        }
 
 } );
diff --git a/lib/resources/jquery.wikibase/toolbar/toolbarlabel.js 
b/lib/resources/jquery.wikibase/toolbar/toolbarlabel.js
index 3a11151..bb4919f 100644
--- a/lib/resources/jquery.wikibase/toolbar/toolbarlabel.js
+++ b/lib/resources/jquery.wikibase/toolbar/toolbarlabel.js
@@ -71,37 +71,6 @@
         */
        isStateChangeable: function() {
                return this.options.stateChangeable;
-       },
-
-       /**
-        * Sets focus on this label.
-        * TODO: Convert setFocus() and removeFocus() to combined focus() 
method or remove if not needed
-        *  anymore.
-        */
-       setFocus: function() {
-               this._makeFocusable();
-               this.element.focus();
-       },
-
-       /**
-        * Removes focus from this label.
-        */
-       removeFocus: function() {
-               this.element.blur();
-       },
-
-       /**
-        * Applies tab index since regular HTML elements cannot be focused.
-        * TODO: Evaluate if still needed since buttons/links are no more 
replaced with <span> when
-        *  disabling.
-        */
-       _makeFocusable: function() {
-               var self = this;
-               this.element.attr( 'tabIndex', '0' );
-               // Do not apply the tab index permanently:
-               this.element.one( 'blur', function( event ) {
-                       self.element.removeAttr( 'tabIndex' );
-               } );
        }
 
 } );
diff --git a/lib/resources/wikibase.ui.PropertyEditTool.js 
b/lib/resources/wikibase.ui.PropertyEditTool.js
index 95f3e6d..3ac449a 100644
--- a/lib/resources/wikibase.ui.PropertyEditTool.js
+++ b/lib/resources/wikibase.ui.PropertyEditTool.js
@@ -135,9 +135,9 @@
                                        && wasPending
                                        && self.hasValue( origin )
                                ) {
-                                       /* focus "add" button after adding a 
value to a multi-value property to
-                                       instantly allow adding another value */
-                                       self._toolbar.$btnAdd.data( 
'toolbarbutton' ).setFocus();
+                                       // Focus "add" button after adding a 
value to a multi-value property to
+                                       // instantly allow adding another value:
+                                       self._toolbar.$btnAdd.focus();
                                }
                        }
                );
diff --git a/lib/tests/qunit/jquery.wikibase/toolbar/toolbarbutton.tests.js 
b/lib/tests/qunit/jquery.wikibase/toolbar/toolbarbutton.tests.js
index 6f1862f..36d95a3 100644
--- a/lib/tests/qunit/jquery.wikibase/toolbar/toolbarbutton.tests.js
+++ b/lib/tests/qunit/jquery.wikibase/toolbar/toolbarbutton.tests.js
@@ -81,7 +81,7 @@
                        'Button is not focused.'
                );
 
-               button.setFocus();
+               $node.focus();
 
                assert.ok(
                        $node.is( ':focus' ),
@@ -89,7 +89,7 @@
                                'from the browser window.)'
                );
 
-               button.removeFocus();
+               $node.blur();
 
                assert.ok(
                        !$node.is( ':focus' ),
@@ -103,7 +103,7 @@
                        'Disabled button.'
                );
 
-               button.setFocus();
+               $node.focus();
 
                assert.ok(
                        $node.is( ':focus' ),
diff --git a/lib/tests/qunit/jquery.wikibase/toolbar/toolbarlabel.tests.js 
b/lib/tests/qunit/jquery.wikibase/toolbar/toolbarlabel.tests.js
index c6cc9d0..96c6978 100644
--- a/lib/tests/qunit/jquery.wikibase/toolbar/toolbarlabel.tests.js
+++ b/lib/tests/qunit/jquery.wikibase/toolbar/toolbarlabel.tests.js
@@ -63,45 +63,6 @@
                );
        } );
 
-       QUnit.test( 'Apply and remove focus.', function( assert ) {
-               var $node = newTestLabel(),
-                       label = $node.data( 'toolbarlabel' );
-
-               // attach label to body to be able to receive focus
-               $node.appendTo( 'body' );
-
-               assert.ok(
-                       !$node.is( ':focus' ),
-                       'Label is not focused.'
-               );
-
-               label.setFocus();
-
-               assert.ok(
-                       $node.is( ':focus' ),
-                       'Label is focused. (An error at this stage might also 
occur if you removed the ' +
-                               'focus from the browser window.)'
-               );
-
-               assert.equal(
-                       $node.prop( 'tabIndex' ),
-                       0,
-                       'Label has tab index.'
-               );
-
-               $node.blur();
-
-               assert.ok(
-                       !$node.is( ':focus' ),
-                       'Blurred label.'
-               );
-
-               assert.ok(
-                       !$node.prop( 'tabIndex' ),
-                       'Removed tab index from label after blurring.'
-               );
-       } );
-
        QUnit.test( 'Disable and enable', function( assert ) {
                var $node = newTestLabel(),
                        label = $node.data( 'toolbarlabel' );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdca1cbd03e25e5b5878f4290fc40d2f3d25dc31
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>

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

Reply via email to