Jforrester has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232888
Change subject: build: Enable jscs rule 'requireSpacesInsideBrackets' and make
pass
......................................................................
build: Enable jscs rule 'requireSpacesInsideBrackets' and make pass
Change-Id: I1306dae8ad04982fa72c74ee7482743f949cae01
---
M .jscsrc
M demos/demo.js
M demos/pages/icons.js
M src/Element.js
M src/core.js
M src/dialogs/MessageDialog.js
M src/dialogs/ProcessDialog.js
M src/layouts/BookletLayout.js
M src/layouts/FieldLayout.js
M src/layouts/IndexLayout.js
M src/mixins/ClippableElement.js
M src/mixins/GroupElement.js
M src/widgets/CapsuleMultiSelectWidget.js
M src/widgets/MenuSelectWidget.js
M src/widgets/OutlineControlsWidget.js
M src/widgets/SelectFileWidget.js
M src/widgets/SelectWidget.js
M src/widgets/TextInputWidget.js
18 files changed, 38 insertions(+), 39 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/88/232888/1
diff --git a/.jscsrc b/.jscsrc
index b1faaa1..1c53bf9 100644
--- a/.jscsrc
+++ b/.jscsrc
@@ -1,6 +1,5 @@
{
"preset": "wikimedia",
- "requireSpacesInsideBrackets": null,
"requireVarDeclFirst": null,
"jsDoc": null
}
diff --git a/demos/demo.js b/demos/demo.js
index 6883b68..5032caf 100644
--- a/demos/demo.js
+++ b/demos/demo.js
@@ -340,7 +340,7 @@
// Theme styles
urls.push( 'dist/oojs-ui' + fragments.slice( 1 ).join( '' ) + '.css' );
for ( i = 0, len = suffixes.length; i < len; i++ ) {
- urls.push( 'dist/oojs-ui' + fragments[1] + suffixes[i] +
fragments.slice( 2 ).join( '' ) + '.css' );
+ urls.push( 'dist/oojs-ui' + fragments[ 1 ] + suffixes[ i ] +
fragments.slice( 2 ).join( '' ) + '.css' );
}
// Demo styles
diff --git a/demos/pages/icons.js b/demos/pages/icons.js
index c34c5e2..193479a 100644
--- a/demos/pages/icons.js
+++ b/demos/pages/icons.js
@@ -301,6 +301,6 @@
.append(
selector.$element,
indicatorsFieldset.$element,
- iconsFieldsets.map( function ( item ) { return
item.$element[0]; } )
+ iconsFieldsets.map( function ( item ) { return
item.$element[ 0 ]; } )
) );
};
diff --git a/src/Element.js b/src/Element.js
index 62c5328..816348b 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -134,7 +134,7 @@
if ( !$elem.length ) {
throw new Error( 'Widget not found: ' + id );
}
- data = $elem.data( 'ooui-infused' ) || $elem[0].oouiInfused;
+ data = $elem.data( 'ooui-infused' ) || $elem[ 0 ].oouiInfused;
if ( data ) {
// cached!
if ( data === true ) {
@@ -211,7 +211,7 @@
// This element is now gone from the DOM, but if anyone is
holding a reference to it,
// let's allow them to OO.ui.infuse() it and do what they
expect (T105828).
// Do not use jQuery.data(), as using it on detached nodes
leaks memory in 1.x line by design.
- $elem[0].oouiInfused = obj;
+ $elem[ 0 ].oouiInfused = obj;
top.resolve();
}
obj.$element.data( 'ooui-infused', obj );
diff --git a/src/core.js b/src/core.js
index b4bf0e3..50accde 100644
--- a/src/core.js
+++ b/src/core.js
@@ -53,7 +53,7 @@
* @return {Boolean} [description]
*/
OO.ui.isFocusableElement = function ( $element ) {
- var node = $element[0],
+ var node = $element[ 0 ],
nodeName = node.nodeName.toLowerCase(),
// Check if the element have tabindex set
isInElementGroup =
/^(input|select|textarea|button|object)$/.test( nodeName ),
@@ -355,7 +355,7 @@
return true;
}
- protocol = url.split( ':', 1 )[0] + ':';
+ protocol = url.split( ':', 1 )[ 0 ] + ':';
if ( !protocol.match( /^([A-za-z0-9\+\.\-])+:/ ) ) {
// Not a valid protocol, safe
return true;
diff --git a/src/dialogs/MessageDialog.js b/src/dialogs/MessageDialog.js
index fb3c37e..ce9ca69 100644
--- a/src/dialogs/MessageDialog.js
+++ b/src/dialogs/MessageDialog.js
@@ -206,7 +206,7 @@
return action.getFlags().indexOf( 'primary' ) >
-1;
} );
if ( actions.length > 0 ) {
- actions[0].$button.focus();
+ actions[ 0 ].$button.focus();
}
}, this );
};
diff --git a/src/dialogs/ProcessDialog.js b/src/dialogs/ProcessDialog.js
index 039ee78..466ca28 100644
--- a/src/dialogs/ProcessDialog.js
+++ b/src/dialogs/ProcessDialog.js
@@ -299,14 +299,14 @@
}
this.$errorItems = $( items );
if ( recoverable ) {
- abilities[this.currentAction] = true;
+ abilities[ this.currentAction ] = true;
// Copy the flags from the first matching action
actions = this.actions.get( { actions: this.currentAction } );
if ( actions.length ) {
- this.retryButton.clearFlags().setFlags(
actions[0].getFlags() );
+ this.retryButton.clearFlags().setFlags( actions[ 0
].getFlags() );
}
} else {
- abilities[this.currentAction] = false;
+ abilities[ this.currentAction ] = false;
this.actions.setAbilities( abilities );
}
if ( warning ) {
diff --git a/src/layouts/BookletLayout.js b/src/layouts/BookletLayout.js
index a225db9..91903b3 100644
--- a/src/layouts/BookletLayout.js
+++ b/src/layouts/BookletLayout.js
@@ -226,7 +226,7 @@
}
// Find all potentially focusable elements in the item
// and check if they are focusable
- items[i].$element
+ items[ i ].$element
.find( 'input, select, textarea, button, object' )
/* jshint loopfunc:true */
.each( checkAndFocus );
diff --git a/src/layouts/FieldLayout.js b/src/layouts/FieldLayout.js
index ab94a32..3e6acf9 100644
--- a/src/layouts/FieldLayout.js
+++ b/src/layouts/FieldLayout.js
@@ -112,10 +112,10 @@
.append( this.fieldWidget.$element );
for ( i = 0; i < this.notices.length; i++ ) {
- this.$messages.append( this.makeMessage( 'notice',
this.notices[i] ) );
+ this.$messages.append( this.makeMessage( 'notice',
this.notices[ i ] ) );
}
for ( i = 0; i < this.errors.length; i++ ) {
- this.$messages.append( this.makeMessage( 'error',
this.errors[i] ) );
+ this.$messages.append( this.makeMessage( 'error', this.errors[
i ] ) );
}
this.setAlignment( config.align );
diff --git a/src/layouts/IndexLayout.js b/src/layouts/IndexLayout.js
index 31cc20c..4d48de5 100644
--- a/src/layouts/IndexLayout.js
+++ b/src/layouts/IndexLayout.js
@@ -203,7 +203,7 @@
}
// Find all potentially focusable elements in the item
// and check if they are focusable
- items[i].$element
+ items[ i ].$element
.find( 'input, select, textarea, button, object' )
.each( checkAndFocus );
}
diff --git a/src/mixins/ClippableElement.js b/src/mixins/ClippableElement.js
index 06281e5..0345cbf 100644
--- a/src/mixins/ClippableElement.js
+++ b/src/mixins/ClippableElement.js
@@ -169,7 +169,7 @@
ccHeight = $container.innerHeight() - buffer,
ccWidth = $container.innerWidth() - buffer,
cWidth = this.$clippable.outerWidth() + buffer,
- scrollerIsWindow = this.$clippableScroller[0] ===
this.$clippableWindow[0],
+ scrollerIsWindow = this.$clippableScroller[ 0 ] ===
this.$clippableWindow[ 0 ],
scrollTop = scrollerIsWindow ?
this.$clippableScroller.scrollTop() : 0,
scrollLeft = scrollerIsWindow ?
this.$clippableScroller.scrollLeft() : 0,
desiredWidth = cOffset.left < 0 ?
diff --git a/src/mixins/GroupElement.js b/src/mixins/GroupElement.js
index ade2c76..90a5802 100644
--- a/src/mixins/GroupElement.js
+++ b/src/mixins/GroupElement.js
@@ -144,7 +144,7 @@
item = this.items[ i ];
if ( item.connect && item.disconnect ) {
remove = {};
- remove[ itemEvent ] = [ 'emit',
this.aggregateItemEvents[itemEvent], item ];
+ remove[ itemEvent ] = [ 'emit',
this.aggregateItemEvents[ itemEvent ], item ];
item.disconnect( this, remove );
}
}
diff --git a/src/widgets/CapsuleMultiSelectWidget.js
b/src/widgets/CapsuleMultiSelectWidget.js
index fd735af..a4e0f30 100644
--- a/src/widgets/CapsuleMultiSelectWidget.js
+++ b/src/widgets/CapsuleMultiSelectWidget.js
@@ -215,8 +215,8 @@
item = null;
for ( j = 0; j < items.length; j++ ) {
- if ( items[j].data === data && items[j].label === label
) {
- item = items[j];
+ if ( items[ j ].data === data && items[ j ].label ===
label ) {
+ item = items[ j ];
items.splice( j, 1 );
break;
}
@@ -303,7 +303,7 @@
} else {
same = true;
for ( i = 0, l = oldItems.length; same && i < l; i++ ) {
- same = same && this.items[i] === oldItems[i];
+ same = same && this.items[ i ] === oldItems[ i ];
}
}
if ( !same ) {
@@ -327,7 +327,7 @@
} else {
same = true;
for ( i = 0, l = oldItems.length; same && i < l; i++ ) {
- same = same && this.items[i] === oldItems[i];
+ same = same && this.items[ i ] === oldItems[ i ];
}
}
if ( !same ) {
@@ -407,7 +407,7 @@
setTimeout( function () {
if (
widget.isVisible() &&
- !OO.ui.contains( widget.$element[0],
document.activeElement, true ) &&
+ !OO.ui.contains( widget.$element[ 0 ],
document.activeElement, true ) &&
( !widget.$autoCloseIgnore ||
!widget.$autoCloseIgnore.has( document.activeElement ).length )
) {
widget.toggle( false );
@@ -554,7 +554,7 @@
if ( this.items ) {
for ( i = 0, len = this.items.length; i < len; i++ ) {
- this.items[i].updateDisabled();
+ this.items[ i ].updateDisabled();
}
}
diff --git a/src/widgets/MenuSelectWidget.js b/src/widgets/MenuSelectWidget.js
index a7a71be..a3cbc08 100644
--- a/src/widgets/MenuSelectWidget.js
+++ b/src/widgets/MenuSelectWidget.js
@@ -135,7 +135,7 @@
filter = showAll ? null : this.getItemMatcher(
this.$input.val() );
for ( i = 0; i < len; i++ ) {
- item = this.items[i];
+ item = this.items[ i ];
if ( item instanceof OO.ui.OptionWidget ) {
item.toggle( showAll || filter( item ) );
}
diff --git a/src/widgets/OutlineControlsWidget.js
b/src/widgets/OutlineControlsWidget.js
index ae90a3c..f8dd560 100644
--- a/src/widgets/OutlineControlsWidget.js
+++ b/src/widgets/OutlineControlsWidget.js
@@ -103,8 +103,8 @@
var ability;
for ( ability in this.abilities ) {
- if ( abilities[ability] !== undefined ) {
- this.abilities[ability] = !!abilities[ability];
+ if ( abilities[ ability ] !== undefined ) {
+ this.abilities[ ability ] = !!abilities[ ability ];
}
}
diff --git a/src/widgets/SelectFileWidget.js b/src/widgets/SelectFileWidget.js
index ff77002..edb3224 100644
--- a/src/widgets/SelectFileWidget.js
+++ b/src/widgets/SelectFileWidget.js
@@ -122,7 +122,7 @@
var $input;
if ( OO.ui.SelectFileWidget.static.isSupportedCache === null ) {
$input = $( '<input type="file">' );
- OO.ui.SelectFileWidget.static.isSupportedCache =
$input[0].files !== undefined;
+ OO.ui.SelectFileWidget.static.isSupportedCache = $input[ 0
].files !== undefined;
}
return OO.ui.SelectFileWidget.static.isSupportedCache;
};
@@ -231,7 +231,7 @@
mime = file.type;
for ( i = 0; i < this.accept.length; i++ ) {
- mimeTest = this.accept[i];
+ mimeTest = this.accept[ i ];
if ( mimeTest === mime ) {
return true;
} else if ( mimeTest.substr( -2 ) === '/*' ) {
@@ -254,8 +254,8 @@
OO.ui.SelectFileWidget.prototype.onFileSelected = function ( e ) {
var file = null;
- if ( e.target.files && e.target.files[0] ) {
- file = e.target.files[0];
+ if ( e.target.files && e.target.files[ 0 ] ) {
+ file = e.target.files[ 0 ];
if ( !this.isFileAcceptable( file ) ) {
file = null;
}
@@ -309,8 +309,8 @@
return false;
}
- if ( dt && dt.files && dt.files[0] ) {
- file = dt.files[0];
+ if ( dt && dt.files && dt.files[ 0 ] ) {
+ file = dt.files[ 0 ];
if ( !this.isFileAcceptable( file ) ) {
file = null;
}
@@ -358,8 +358,8 @@
return false;
}
- if ( dt && dt.files && dt.files[0] ) {
- file = dt.files[0];
+ if ( dt && dt.files && dt.files[ 0 ] ) {
+ file = dt.files[ 0 ];
if ( !this.isFileAcceptable( file ) ) {
file = null;
}
diff --git a/src/widgets/SelectWidget.js b/src/widgets/SelectWidget.js
index c4d8f3c..3cb8fc8 100644
--- a/src/widgets/SelectWidget.js
+++ b/src/widgets/SelectWidget.js
@@ -570,7 +570,7 @@
filter = this.getItemMatcher( label, true );
for ( i = 0; i < len; i++ ) {
- item = this.items[i];
+ item = this.items[ i ];
if ( item instanceof OO.ui.OptionWidget && item.isSelectable()
&& filter( item ) ) {
return item;
}
@@ -580,7 +580,7 @@
found = null;
filter = this.getItemMatcher( label, false );
for ( i = 0; i < len; i++ ) {
- item = this.items[i];
+ item = this.items[ i ];
if ( item instanceof OO.ui.OptionWidget &&
item.isSelectable() && filter( item ) ) {
if ( found ) {
return null;
diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 4e0993b..b63db12 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -314,7 +314,7 @@
}
// Find topmost node in the tree
- topmostNode = this.$element[0];
+ topmostNode = this.$element[ 0 ];
while ( topmostNode.parentNode ) {
topmostNode = topmostNode.parentNode;
}
@@ -348,7 +348,7 @@
};
// Create a fake parent and observe it
- fakeParentNode = $( '<div>' ).append( topmostNode )[0];
+ fakeParentNode = $( '<div>' ).append( topmostNode )[ 0 ];
mutationObserver.observe( fakeParentNode, { childList: true } );
} else {
// Using the DOMNodeInsertedIntoDocument event is much nicer
and less magical, and works for
@@ -467,7 +467,7 @@
*/
OO.ui.TextInputWidget.prototype.moveCursorToEnd = function () {
var textRange,
- element = this.$input[0];
+ element = this.$input[ 0 ];
this.focus();
if ( element.selectionStart !== undefined ) {
element.selectionStart = element.selectionEnd =
element.value.length;
--
To view, visit https://gerrit.wikimedia.org/r/232888
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1306dae8ad04982fa72c74ee7482743f949cae01
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits