From 96fcbbd695031a9074bdd853aff5238d1ce0dda4 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Mon, 19 Nov 2012 17:05:34 -0800 Subject: [PATCH] Cleanup var statements Put non-assignment vars first Change-Id: Id868976bc4d7c21032aef5020fe5fd0eb5df7a14 --- modules/ve/ce/ve.ce.Surface.js | 47 ++++++++----------- modules/ve/dm/ve.dm.SurfaceFragment.js | 3 +- .../ve/ui/inspectors/ve.ui.LinkInspector.js | 8 ++-- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index d19c6380d9..705d0c1bfa 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -83,7 +83,8 @@ ve.ce.Surface.static.$phantomTemplate = $( '
0 && offsetDiff === lengthDiff /* && sameLeadingAndTrailing */) { data = next.text.substring( @@ -601,10 +598,8 @@ ve.ce.Surface.prototype.onPaste = function () { $( '#paste' ).html( '' ).show().focus(); setTimeout( function () { - var key = '', - pasteText, - pasteData, - tx; + var pasteText, pasteData, tx, + key = ''; // Create key from text and element names $( '#paste' ).hide().contents().each( function () { @@ -799,8 +794,7 @@ ve.ce.Surface.prototype.handleEnter = function ( e ) { * @param {Boolean} Key was a backspace */ ve.ce.Surface.prototype.handleDelete = function ( e, backspace ) { - var selection = this.model.getSelection(), - sourceOffset, + var sourceOffset, targetOffset, sourceSplitableNode, targetSplitableNode, @@ -814,7 +808,8 @@ ve.ce.Surface.prototype.handleDelete = function ( e, backspace ) { adjacentText, adjacentTextAfterMatch, endOffset, - i; + i, + selection = this.model.getSelection(); if ( selection.from === selection.to ) { // Set source and target linmod offsets @@ -963,10 +958,9 @@ ve.ce.Surface.prototype.showCursor = function ( offset ) { * @param {ve.Range} range Range to show selection on */ ve.ce.Surface.prototype.showSelection = function ( range ) { - var rangySel = rangy.getSelection(), - rangyRange = rangy.createRange(), - start, - end; + var start, end, + rangySel = rangy.getSelection(), + rangyRange = rangy.createRange(); if ( range.start !== range.end ) { start = this.getNodeAndOffset( range.start ); @@ -1026,8 +1020,8 @@ ve.ce.Surface.prototype.showSelection = function ( range ) { */ ve.ce.Surface.prototype.getNearestCorrectOffset = function ( offset, direction ) { var contentOffset, structuralOffset; - direction = direction > 0 ? 1 : -1; + direction = direction > 0 ? 1 : -1; if ( ve.dm.Document.isContentOffset( this.documentView.model.data, offset ) || this.hasSlugAtOffset( offset ) @@ -1081,8 +1075,8 @@ ve.ce.Surface.prototype.hasSlugAtOffset = function ( offset ) { * offset is the position within the element */ ve.ce.Surface.prototype.getNodeAndOffset = function ( offset ) { - var slug = this.documentView.getSlugAtOffset( offset ), - node, startOffset, current, stack, item, $item, length; + var node, startOffset, current, stack, item, $item, length, + slug = this.documentView.getSlugAtOffset( offset ); if ( slug ) { return { node: slug[0].childNodes[0], offset: 0 }; } @@ -1172,8 +1166,7 @@ ve.ce.Surface.isShortcutKey = function ( e ) { * @method */ ve.ce.Surface.clearLocalStorage = function () { - var i, len, key, - time, now, + var i, len, key, time, now, keysToRemove = []; for ( i = 0, len = localStorage.length; i < len; i++ ) { diff --git a/modules/ve/dm/ve.dm.SurfaceFragment.js b/modules/ve/dm/ve.dm.SurfaceFragment.js index 094acea17d..c085db99f1 100644 --- a/modules/ve/dm/ve.dm.SurfaceFragment.js +++ b/modules/ve/dm/ve.dm.SurfaceFragment.js @@ -513,7 +513,8 @@ ve.dm.SurfaceFragment.prototype.convertNodes = function ( type, attr ) { if ( !this.surface ) { return this; } - var tx = ve.dm.Transaction.newFromContentBranchConversion( this.document, this.range, type, attr ); + var tx = + ve.dm.Transaction.newFromContentBranchConversion( this.document, this.range, type, attr ); this.surface.change( tx, !this.noAutoSelect && tx.translateRange( this.range ) ); return this; }; diff --git a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js index ed432b65a5..f8bd36f319 100644 --- a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js +++ b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js @@ -226,12 +226,10 @@ ve.ui.LinkInspector.prototype.initMultiSuggest = function () { 'cssEllipsis': false, // Build suggestion groups in order. 'suggestions': function ( params ) { - var groups = {}, + var modifiedQuery, title, prot, + groups = {}, results = params.results, - query = params.query, - modifiedQuery, - title, - prot; + query = params.query; // Add existing pages. if ( results.length > 0 ) {