Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/171868
Change subject: Allow submitting linkItem form with enter
......................................................................
Allow submitting linkItem form with enter
And be smarter about enabling/ disabling the submit button.
Bug: 72807
Change-Id: Ib3e9ebf1d58874fed127ba6830f76b441e21cb8e
---
M client/resources/Resources.php
M client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
2 files changed, 13 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/68/171868/1
diff --git a/client/resources/Resources.php b/client/resources/Resources.php
index c591f28..83ebb79 100644
--- a/client/resources/Resources.php
+++ b/client/resources/Resources.php
@@ -84,6 +84,7 @@
'mediawiki.api',
'mediawiki.util',
'mediawiki.jqueryMsg',
+ 'jquery.event.special.eachchange',
'wikibase.client.currentSite',
'wikibase.sites',
'wikibase.RepoApi',
diff --git a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
b/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
index e1bc376..d04ee65 100644
--- a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
+++ b/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
@@ -320,6 +320,8 @@
* @return {jQuery}
*/
_createPageInput: function() {
+ var self = this;
+
return $( '<label>' )
.attr( 'for', 'wbclient-linkItem-page' )
.text( mw.msg( 'wikibase-linkitem-input-page' ) )
@@ -331,10 +333,16 @@
disabled: 'disabled',
'class' : 'wbclient-linkItem-input'
} )
- .on( 'focus', $.proxy( function () {
- // Enable the button by the time the user uses
this field
- this.$goButton.button( 'enable' );
- }, this ) )
+ .on( 'eachchange', function () {
+ // Enable the button if the field has a value
+ self.$goButton.button( $( this ).val() === '' ?
'disable' : 'enable' );
+ } )
+ .on( 'keypress', function( e ) {
+ if ( !self.$goButton.prop( 'disabled' ) &&
e.which === 13 ) {
+ // Enter should submit
+ self.$goButton.trigger( 'click' );
+ }
+ } )
);
},
--
To view, visit https://gerrit.wikimedia.org/r/171868
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3e9ebf1d58874fed127ba6830f76b441e21cb8e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits