Code style fixes

* "function(" -> "function ("
* "{String}" -> "{string}"
* collapse unintentional double spaces

Change-Id: I3ce3f02d1e31d4797b44e04d28457dec363be296
This commit is contained in:
Ed Sanders 2013-05-06 12:34:32 +01:00
parent 44940b4551
commit 830de420e1
25 changed files with 59 additions and 59 deletions

View file

@ -178,7 +178,7 @@ ve.ce.AlienNode.prototype.positionPhantoms = function () {
*
* @method
*/
ve.ce.AlienNode.prototype.clearPhantoms = function() {
ve.ce.AlienNode.prototype.clearPhantoms = function () {
var surface = this.root.getSurface();
surface.replacePhantoms( null );
surface.$.unbind( '.phantoms' );

View file

@ -730,9 +730,9 @@ ve.ce.Surface.prototype.onContentChange = function ( node, previous, next ) {
(
lengthDiff > 0 &&
previous.text.substring( 0, previousStart ) ===
next.text.substring( 0, previousStart ) &&
next.text.substring( 0, previousStart ) &&
previous.text.substring( previousStart ) ===
next.text.substring( nextStart )
next.text.substring( nextStart )
) ||
(
lengthDiff < 0 &&
@ -928,7 +928,7 @@ ve.ce.Surface.prototype.handleLeftOrRightArrowKey = function ( e ) {
offsetDelta,
e.altKey === true || e.ctrlKey === true ? 'word' : 'character' // unit
);
if ( e.shiftKey === true ) { // expanded range
if ( e.shiftKey === true ) { // expanded range
range = new ve.Range( selection.from, offset );
} else { // collapsed range (just a cursor)
range = new ve.Range( offset );
@ -964,13 +964,13 @@ ve.ce.Surface.prototype.handleUpOrDownArrowKey = function ( e ) {
rangyRange = rangy.createRange();
rangyRange.selectNode( $element[0] );
rangySelection.setSingleRange( rangyRange );
setTimeout( ve.bind( function() {
setTimeout( ve.bind( function () {
if ( !$element.hasClass( 've-ce-slug' ) ) {
$element.remove();
}
this.surfaceObserver.start();
this.surfaceObserver.stop( false );
if ( e.shiftKey === true ) { // expanded range
if ( e.shiftKey === true ) { // expanded range
range = new ve.Range( selection.from, this.model.getSelection().to );
} else { // collapsed range (just a cursor)
range = new ve.Range( this.model.getSelection().to );
@ -1352,7 +1352,7 @@ ve.ce.Surface.prototype.showSelection = function ( range ) {
* @method
* @param {jQuery} $phantoms Phantoms to append
*/
ve.ce.Surface.prototype.replacePhantoms = function( $phantoms ) {
ve.ce.Surface.prototype.replacePhantoms = function ( $phantoms ) {
this.$phantoms.empty().append( $phantoms );
};

View file

@ -246,7 +246,7 @@ ve.ce.getOffsetFromElementNode = function ( domNode, domOffset, addOuterLength )
* @returns {number} Linear model offset
* @throws {Error}
*/
ve.ce.getOffsetOfSlug = function ( $node ) {
ve.ce.getOffsetOfSlug = function ( $node ) {
var model;
if ( $node.index() === 0 ) {
model = $node.parent().data( 'view' ).getModel();

View file

@ -39,7 +39,7 @@ ve.dm.GeneratedContentNode.static.enableAboutGrouping = true;
* @param {ve.dm.IndexValueStore} store Index-value store
* @returns {number} Index of stored data
*/
ve.dm.GeneratedContentNode.static.storeDomElements = function( dataElement, domElements, store ) {
ve.dm.GeneratedContentNode.static.storeDomElements = function ( dataElement, domElements, store ) {
var hash = ve.getHash( this.getHashObject( dataElement ) );
return store.index( domElements, hash );
};

View file

@ -139,7 +139,7 @@ ve.dm.Converter.prototype.getHtmlDocument = function () {
* @method
* @returns {Object|null} Context object, or null if not converting
*/
ve.dm.Converter.prototype.getCurrentContext = function () {
ve.dm.Converter.prototype.getCurrentContext = function () {
return this.contextStack === null ? null : this.contextStack[this.contextStack.length - 1];
};

View file

@ -25,7 +25,7 @@ ve.inheritClass( ve.dm.DataString, unicodeJS.TextString );
* @param {number} position Position in data to read from
* @returns {string|null} Character at position, or null if not text
*/
ve.dm.DataString.prototype.read = function( position ) {
ve.dm.DataString.prototype.read = function ( position ) {
var dataAt = this.data[position];
// check data is present at position and is not an element
if ( dataAt !== undefined && dataAt.type === undefined ) {

View file

@ -292,7 +292,7 @@ ve.dm.Document.prototype.getInternalList = function () {
* @param {Array} insert Element data being inserted
* @returns {Object} Metadata replace operation to keep data & metadata in sync
*/
ve.dm.Document.prototype.getMetadataReplace = function( offset, remove, insert ) {
ve.dm.Document.prototype.getMetadataReplace = function ( offset, remove, insert ) {
var removeMetadata, insertMetadata, replace = {};
if ( remove > insert.length ) {
// if we are removing more than we are inserting we need to collapse the excess metadata

View file

@ -26,8 +26,8 @@ ve.dm.IndexValueStore = function VeDmIndexValueStore() {
* If the hash is not found the value is added to the store.
*
* @method
* @param {Object|String|Array} value Value to lookup or store
* @param {String} [hash] Value hash. Uses ve.getHash( value ) if not provided.
* @param {Object|string|Array} value Value to lookup or store
* @param {string} [hash] Value hash. Uses ve.getHash( value ) if not provided.
* @returns {number} The index of the value in the store
*/
ve.dm.IndexValueStore.prototype.index = function ( value, hash ) {
@ -55,7 +55,7 @@ ve.dm.IndexValueStore.prototype.index = function ( value, hash ) {
* Returns null if the hash is not found.
*
* @method
* @param {Object|String|Array} hash Value hash.
* @param {Object|string|Array} hash Value hash.
* @returns {number|null} The index of the value in the store, or undefined if it is not found
*/
ve.dm.IndexValueStore.prototype.indexOfHash = function ( hash ) {

View file

@ -288,7 +288,7 @@ ve.dm.MetaList.prototype.removeMeta = function ( item ) {
* insertItem().
*
* @param {number} offset Offset in the linear model of the new item
* @param {number} index Index of the new item in the metadata array at offset
* @param {number} index Index of the new item in the metadata array at offset
* @param {ve.dm.MetaItem} item Item object
* @emits insert
*/

View file

@ -207,7 +207,7 @@ ve.dm.Surface.prototype.removeInsertionAnnotation = function ( annotation ) {
* @method
* @returns {boolean} Has a future state
*/
ve.dm.Surface.prototype.hasFutureState = function() {
ve.dm.Surface.prototype.hasFutureState = function () {
return this.undoIndex > 0;
};
@ -217,7 +217,7 @@ ve.dm.Surface.prototype.hasFutureState = function() {
* @method
* @returns {boolean} Has a past state
*/
ve.dm.Surface.prototype.hasPastState = function() {
ve.dm.Surface.prototype.hasPastState = function () {
return this.bigStack.length - this.undoIndex > 0;
};
@ -258,7 +258,7 @@ ve.dm.Surface.prototype.getFragment = function ( range, noAutoSelect ) {
* @method
* @emits history
*/
ve.dm.Surface.prototype.truncateUndoStack = function() {
ve.dm.Surface.prototype.truncateUndoStack = function () {
this.bigStack = this.bigStack.slice( 0, this.bigStack.length - this.undoIndex );
this.undoIndex = 0;
this.emit( 'history' );
@ -371,7 +371,7 @@ ve.dm.Surface.prototype.change = function ( transactions, selection ) {
}
// Only emit one context change event
if ( contextChange ) {
if ( contextChange ) {
this.emit( 'contextChange' );
}

View file

@ -755,7 +755,7 @@ ve.init.mw.ViewPageTarget.prototype.setupSkinTabs = function () {
action = this.pageExists ? 'edit' : 'create';
pTabsId = $( '#p-views' ).length ? 'p-views' : 'p-cactions';
// Add independent "VisualEditor" tab (#ca-ve-edit).
// Add independent "VisualEditor" tab (#ca-ve-edit).
if ( this.tabLayout === 'add' ) {
caVeEdit = mw.util.addPortletLink(
@ -1421,7 +1421,7 @@ ve.init.mw.ViewPageTarget.prototype.attachToolbar = function () {
this.$toolbarWrapper = $( '.ve-ui-toolbar-wrapper' )
.insertBefore( $( '#firstHeading' ) )
.find( '.ve-ui-toolbar' )
.slideDown( 'fast', ve.bind( function() {
.slideDown( 'fast', ve.bind( function () {
this.surface.getContext().update();
}, this ) )
.end();

View file

@ -41,7 +41,7 @@ QUnit.test( 'convert', function ( assert ) {
'type': 'MWheading',
'attributes': { level: 2 },
'expectedSelection': new ve.Range( 14, 16 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 11, 2, { 'type': '/list' }, { 'type': 'MWheading', 'attributes': { 'level': 2 } } );
data.splice( 19, 2, { 'type': '/MWheading' }, { 'type': 'list', 'attributes': { 'style': 'bullet' } } );
},
@ -52,7 +52,7 @@ QUnit.test( 'convert', function ( assert ) {
'type': 'MWheading',
'attributes': { level: 3 },
'expectedSelection': new ve.Range( 15, 44 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 11, 2, { 'type': '/list' }, { 'type': 'MWheading', 'attributes': { 'level': 3 } } );
data.splice( 19, 4, { 'type': '/MWheading' }, { 'type': 'MWheading', 'attributes': { 'level': 3 } } );
data.splice( 27, 4, { 'type': '/MWheading' }, { 'type': 'MWheading', 'attributes': { 'level': 3 } } );
@ -66,7 +66,7 @@ QUnit.test( 'convert', function ( assert ) {
'type': 'MWheading',
'attributes': { level: 1 },
'expectedSelection': new ve.Range( 2, 22 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 0, 3, { 'type': 'MWheading', 'attributes': { 'level': 1 } } );
data.splice( 7, 4, { 'type': '/MWheading' }, { 'type': 'MWheading', 'attributes': { 'level': 1 } } );
data.splice( 15, 4, { 'type': '/MWheading' }, { 'type': 'MWheading', 'attributes': { 'level': 1 } } );
@ -79,7 +79,7 @@ QUnit.test( 'convert', function ( assert ) {
'type': 'MWpreformatted',
'attributes': undefined,
'expectedSelection': new ve.Range( 3, 20 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 0, 3, { 'type': 'MWpreformatted' } );
data.splice( 7, 4, { 'type': '/MWpreformatted' }, { 'type': 'MWpreformatted' } );
data.splice( 15, 4, { 'type': '/MWpreformatted' }, { 'type': 'MWpreformatted' } );
@ -92,7 +92,7 @@ QUnit.test( 'convert', function ( assert ) {
'type': 'paragraph',
'attributes': undefined,
'expectedSelection': new ve.Range( 146, 159 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 145, 1, { 'type': 'paragraph' } );
data.splice( 159, 1, { 'type': '/paragraph' } );
},
@ -103,7 +103,7 @@ QUnit.test( 'convert', function ( assert ) {
'type': 'paragraph',
'attributes': undefined,
'expectedSelection': new ve.Range( 165, 180 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 162, 1, { 'type': 'paragraph' } );
data.splice( 183, 1, { 'type': '/paragraph' } );
},

View file

@ -43,11 +43,11 @@ QUnit.test( 'decrease', 2, function ( assert ) {
'range': new ve.Range( 14, 16 ),
'method': 'decrease',
'expectedSelection': new ve.Range( 14, 16 ),
'expectedData': function( data ) {
'expectedData': function ( data ) {
data.splice( 11, 2, { 'type': '/list' }, { 'type': 'paragraph' } );
data.splice( 19, 2, { 'type': '/paragraph' }, { 'type': 'list', 'attributes': { 'style': 'bullet' } } );
},
'expectedOriginalData': function( data ) {
'expectedOriginalData': function ( data ) {
// generated: 'wrapper' is removed by the action and not restored by undo
delete data[12].internal;
},

View file

@ -47,11 +47,11 @@ QUnit.test( 'synchronize', 6, function ( assert ) {
firstTextNodeLengthChanges.push( diff );
} );
doc.getDocumentNode().getChildren()[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0]
.on( 'update', function () {
.on( 'update', function () {
secondTextNodeUpdates++;
} );
doc.getDocumentNode().getChildren()[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0]
.on( 'annotation', function () {
.on( 'annotation', function () {
secondTextNodeAnnotations++;
} );
doc.getDocumentNode().getChildren()[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0]

View file

@ -417,7 +417,7 @@ QUnit.test( 'wrapAllNodes', 10, function ( assert ) {
fragment = new ve.dm.SurfaceFragment( surface, new ve.Range( 5, 37 ) );
assert.throws( function() {
assert.throws( function () {
fragment.unwrapNodes( 0, 20 );
}, /cannot unwrap by greater depth/, 'error thrown trying to unwrap more nodes that it is possible to contain' );
@ -504,19 +504,19 @@ function runIsolateTest( assert, type, range, expected, label ) {
}
QUnit.test( 'isolateAndUnwrap', 4, function ( assert ) {
runIsolateTest( assert, 'MWheading', new ve.Range( 12, 20 ), function( data ) {
runIsolateTest( assert, 'MWheading', new ve.Range( 12, 20 ), function ( data ) {
data.splice( 11, 0, { 'type': '/list' } );
data.splice( 12, 1 );
data.splice( 20, 1, { 'type': 'list', 'attributes': { 'style': 'bullet' } });
}, 'isolating paragraph in list item "Item 2" for MWheading');
runIsolateTest( assert, 'heading', new ve.Range( 12, 20 ), function( data ) {
runIsolateTest( assert, 'heading', new ve.Range( 12, 20 ), function ( data ) {
data.splice( 11, 0, { 'type': 'listItem' } );
data.splice( 12, 1 );
data.splice( 20, 1, { 'type': '/listItem' });
}, 'isolating paragraph in list item "Item 2" for heading');
runIsolateTest( assert, 'MWheading', new ve.Range( 89, 97 ), function( data ) {
runIsolateTest( assert, 'MWheading', new ve.Range( 89, 97 ), function ( data ) {
data.splice( 88, 1,
{ 'type': '/tableRow' },
{ 'type': '/tableSection' },
@ -529,7 +529,7 @@ QUnit.test( 'isolateAndUnwrap', 4, function ( assert ) {
);
}, 'isolating "Cell 2" for MWheading');
runIsolateTest( assert, 'MWheading', new ve.Range( 202, 212 ), function( data ) {
runIsolateTest( assert, 'MWheading', new ve.Range( 202, 212 ), function ( data ) {
data.splice( 201, 1,
{ 'type': '/list' }, { 'type': '/listItem' }, { 'type': '/list' }
);

View file

@ -1448,7 +1448,7 @@ QUnit.test( 'push*Annotating', function ( assert ) {
runBuilderTests( assert, cases );
} );
QUnit.test( 'newFromMetadataInsertion', function( assert ) {
QUnit.test( 'newFromMetadataInsertion', function ( assert ) {
var doc = ve.dm.example.createExampleDocument( 'withMeta' ),
element = {
'type': 'alienMeta',
@ -1489,7 +1489,7 @@ QUnit.test( 'newFromMetadataInsertion', function( assert ) {
runConstructorTests( assert, ve.dm.Transaction.newFromMetadataInsertion, cases );
} );
QUnit.test( 'newFromMetadataRemoval', function( assert ) {
QUnit.test( 'newFromMetadataRemoval', function ( assert ) {
var doc = ve.dm.example.createExampleDocument( 'withMeta' ),
allElements = ve.dm.example.withMetaMetaData[11],
someElements = allElements.slice( 1, 3 ),
@ -1533,7 +1533,7 @@ QUnit.test( 'newFromMetadataRemoval', function( assert ) {
runConstructorTests( assert, ve.dm.Transaction.newFromMetadataRemoval, cases );
} );
QUnit.test( 'newFromMetadataElementReplacement', function( assert ) {
QUnit.test( 'newFromMetadataElementReplacement', function ( assert ) {
var doc = ve.dm.example.createExampleDocument( 'withMeta' ),
newElement = {
'type': 'alienMeta',

View file

@ -254,7 +254,7 @@ QUnit.test( 'commit/rollback', function ( assert ) {
['pushRetainMetadata', 2 ],
['pushRetain', 1 ],
],
'expected': function( data ) {
'expected': function ( data ) {
data.splice( 25, 0, metaElementInsert, metaElementInsertClose );
}
},
@ -265,7 +265,7 @@ QUnit.test( 'commit/rollback', function ( assert ) {
['pushReplaceMetadata', [], [ metaElementInsert ] ],
['pushRetain', 9 ],
],
'expected': function( data ) {
'expected': function ( data ) {
data.splice( 7, 0, metaElementInsert, metaElementInsertClose );
}
},
@ -276,7 +276,7 @@ QUnit.test( 'commit/rollback', function ( assert ) {
['pushReplaceMetadata', ve.dm.example.withMetaMetaData[11], [] ],
['pushRetain', 1 ],
],
'expected': function( data ) {
'expected': function ( data ) {
data.splice( 21, 8 );
}
},
@ -289,7 +289,7 @@ QUnit.test( 'commit/rollback', function ( assert ) {
['pushRetainMetadata', 1 ],
['pushRetain', 1 ],
],
'expected': function( data ) {
'expected': function ( data ) {
data.splice( 23, 4 );
}
},
@ -301,7 +301,7 @@ QUnit.test( 'commit/rollback', function ( assert ) {
['pushReplaceMetadata', [ ve.dm.example.withMetaMetaData[11][3] ], [ metaElementInsert ] ],
['pushRetain', 1 ],
],
'expected': function( data ) {
'expected': function ( data ) {
data.splice( 27, 2, metaElementInsert, metaElementInsertClose );
}
},
@ -312,7 +312,7 @@ QUnit.test( 'commit/rollback', function ( assert ) {
['pushReplace', 7, 2, []],
['pushRetain', 2 ],
],
'expected': function( data ) {
'expected': function ( data ) {
data.splice( 15, 2 );
}
}

View file

@ -96,7 +96,7 @@ ve.dm.example.span = { 'type': 'textStyle/span' };
* @returns {ve.dm.Document} Document
* @throws {Error} Example data not found
*/
ve.dm.example.createExampleDocument = function( name, store ) {
ve.dm.example.createExampleDocument = function ( name, store ) {
name = name || 'data';
store = store || new ve.dm.IndexValueStore();
if ( ve.dm.example[name] === undefined ) {
@ -991,7 +991,7 @@ ve.dm.example.domToDataCases = {
'storeItems': [
ve.dm.example.MWTemplate.blockStoreItems
],
'modify': function( data ) {
'modify': function ( data ) {
data[0].attributes.mw.params['1'].wt = 'Hello, globe!';
},
'normalizedHtml': ve.dm.example.MWTemplate.blockSpanModified
@ -1020,7 +1020,7 @@ ve.dm.example.domToDataCases = {
'storeItems': [
ve.dm.example.MWTemplate.inlineStoreItems
],
'modify': function( data ) {
'modify': function ( data ) {
data[1].attributes.mw.params['1'].wt = '5,678';
},
'normalizedHtml': ve.dm.example.MWTemplate.inlineOpenModified + ve.dm.example.MWTemplate.inlineClose

View file

@ -83,7 +83,7 @@ ve.ui.Inspector.prototype.onCloseButtonClick = function () {
*
* @method
*/
ve.ui.Inspector.prototype.onRemoveButtonClick = function() {
ve.ui.Inspector.prototype.onRemoveButtonClick = function () {
this.close( 'remove' );
};

View file

@ -95,7 +95,7 @@ ve.ui.InputWidget.prototype.getValue = function () {
* @method
* @param {boolean} isRTL
*/
ve.ui.InputWidget.prototype.setRTL = function( isRTL ) {
ve.ui.InputWidget.prototype.setRTL = function ( isRTL ) {
if ( isRTL ) {
this.$input.removeClass( 've-ui-ltr' );
this.$input.addClass( 've-ui-rtl' );

View file

@ -82,7 +82,7 @@ ve.ui.MWCategoryInputWidget.prototype.getLookupRequest = function () {
ve.ui.MWCategoryInputWidget.prototype.getLookupCacheItemFromData = function ( data ) {
return ve.isArray( data ) && data.length ?
data[1].map( ve.bind( function ( item ) {
return item.replace( new RegExp( this.categoryPrefix, 'gi' ), '' );
return item.replace( new RegExp( this.categoryPrefix, 'gi' ), '' );
}, this ) ) :
[];
};

View file

@ -35,7 +35,7 @@ ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) {
// Events
this.$categoryItem.on( {
'click': ve.bind( this.onClick, this ),
'click': ve.bind( this.onClick, this ),
'mounsedown': ve.bind( this.onMouseDown, this )
} );

View file

@ -94,7 +94,7 @@ ve.ui.MWCategoryWidget.prototype.onLookupInputKeyDown = function ( e ) {
*/
ve.ui.MWCategoryWidget.prototype.onLookupMenuItemSelect = function ( item ) {
if ( item && item.getData() !== '' ) {
this.emit( 'newCategory', this.categoryInput.getCategoryItemFromValue( item.getData() ) );
this.emit( 'newCategory', this.categoryInput.getCategoryItemFromValue( item.getData() ) );
this.categoryInput.setValue( '' );
}
};
@ -102,7 +102,7 @@ ve.ui.MWCategoryWidget.prototype.onLookupMenuItemSelect = function ( item ) {
/**
* Calls metaItem remove method
*
* @param {String} name category name
* @param {string} name category name
*/
ve.ui.MWCategoryWidget.prototype.onRemoveCategory = function ( name ) {
this.categories[name].metaItem.remove();
@ -111,8 +111,8 @@ ve.ui.MWCategoryWidget.prototype.onRemoveCategory = function ( name ) {
/**
* Update sortkey value, emit upsteSortkey event
*
* @param {String} name
* @param {String} value
* @param {string} name
* @param {string} value
*/
ve.ui.MWCategoryWidget.prototype.onUpdateSortkey = function ( name, value ) {
this.categories[name].sortKey = value;

View file

@ -42,7 +42,7 @@ ve.TriggerRegistry.prototype.register = function ( name, trigger ) {
if ( typeof name !== 'string' && !ve.isArray( name ) ) {
throw new Error( 'name must be a string or array, cannot be a ' + typeof name );
}
if ( !( trigger instanceof ve.Trigger ) && !ve.isPlainObject( trigger ) ) {
if ( !( trigger instanceof ve.Trigger ) && !ve.isPlainObject( trigger ) ) {
throw new Error(
'trigger must be an instance of ve.Trigger or an object containing instances of ' +
've.Trigger, cannot be a ' + typeof trigger

View file

@ -1063,7 +1063,7 @@
// `<pre>Foo</pre>` or `<pre>\nFoo</pre>` , but that's a syntactic difference, not a
// semantic one, and handling that is Parsoid's job.
$element = $( element ).clone();
$element.find( 'pre, textarea, listing' ).each( function() {
$element.find( 'pre, textarea, listing' ).each( function () {
var matches;
if ( this.firstChild && this.firstChild.nodeType === Node.TEXT_NODE ) {
matches = this.firstChild.data.match( /^(\r\n|\r|\n)/ );