From 5da622b0d8af230f0f9964d5dc2c25eef22f293f Mon Sep 17 00:00:00 2001 From: Stephen O'Loughlin Date: Wed, 18 Oct 2017 14:57:01 +0100 Subject: [PATCH] Update code style to be consistent throughout --- js/isotope.js | 54 ++++++++++++++++++------------------- js/item.js | 4 +-- js/layout-mode.js | 6 ++--- js/layout-modes/fit-rows.js | 4 +-- js/layout-modes/masonry.js | 6 ++--- js/layout-modes/vertical.js | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/js/isotope.js b/js/isotope.js index 800341f..36054cb 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -32,16 +32,16 @@ // CommonJS module.exports = factory( window, - require('outlayer'), - require('get-size'), - require('desandro-matches-selector'), - require('fizzy-ui-utils'), - require('./item'), - require('./layout-mode'), + require( 'outlayer' ), + require( 'get-size' ), + require( 'desandro-matches-selector' ), + require( 'fizzy-ui-utils' ), + require( './item' ), + require( './layout-mode' ), // include default layout modes - require('./layout-modes/masonry'), - require('./layout-modes/fit-rows'), - require('./layout-modes/vertical') + require( './layout-modes/masonry' ), + require( './layout-modes/fit-rows' ), + require( './layout-modes/vertical' ) ); } else { // browser global @@ -120,7 +120,7 @@ var trim = String.prototype.trim ? var items = Outlayer.prototype._itemize.apply( this, arguments ); // assign ID for original-order for ( var i=0; i < items.length; i++ ) { - var item = items[i]; + var item = items[ i ]; item.id = this.itemGUID++; } this._updateItemsSortData( items ); @@ -144,7 +144,7 @@ var trim = String.prototype.trim ? proto.layout = function() { // if first time doing layout, do all magic - if ( !this._isLayoutInited && this._getOption('initLayout') ) { + if ( !this._isLayoutInited && this._getOption( 'initLayout' ) ) { this.arrange(); return; } @@ -198,7 +198,7 @@ var trim = String.prototype.trim ? // Don't animate/transition first layout // Or don't animate/transition other layouts proto._getIsInstant = function() { - var isLayoutInstant = this._getOption('layoutInstant'); + var isLayoutInstant = this._getOption( 'layoutInstant' ); var isInstant = isLayoutInstant !== undefined ? isLayoutInstant : !this._isLayoutInited; this._isInstant = isInstant; @@ -243,7 +243,7 @@ var trim = String.prototype.trim ? // test each item for ( var i=0; i < items.length; i++ ) { - var item = items[i]; + var item = items[ i ]; if ( item.isIgnored ) { continue; } @@ -328,7 +328,7 @@ var trim = String.prototype.trim ? var len = items && items.length; for ( var i=0; len && i < len; i++ ) { - var item = items[i]; + var item = items[ i ]; item.updateSortData(); } }; @@ -349,14 +349,14 @@ var trim = String.prototype.trim ? return sorter; } // parse the sorter string - var args = trim( sorter ).split(' '); - var query = args[0]; + var args = trim( sorter ).split( ' ' ); + var query = args[ 0 ]; // check if query looks like [an-attribute] var attrMatch = query.match( /^\[(.+)\]$/ ); - var attr = attrMatch && attrMatch[1]; + var attr = attrMatch && attrMatch[ 1 ]; var getValue = getValueGetter( attr, query ); // use second argument as a parser - var parser = Isotope.sortDataParsers[ args[1] ]; + var parser = Isotope.sortDataParsers[ args[ 1 ] ]; // parse the value, if there was a parser sorter = parser ? function( elem ) { return elem && parser( getValue( elem ) ); @@ -419,7 +419,7 @@ var trim = String.prototype.trim ? // check if sortBys is same as start of sortHistory proto._getIsSameSortBy = function( sortBys ) { for ( var i=0; i < sortBys.length; i++ ) { - if ( sortBys[i] != this.sortHistory[i] ) { + if ( sortBys[ i ] != this.sortHistory[ i ] ) { return false; } } @@ -430,8 +430,8 @@ var trim = String.prototype.trim ? function getItemSorter( sortBys, sortAsc ) { return function sorter( itemA, itemB ) { // cycle through all sortKeys - for ( var i = 0; i < sortBys.length; i++ ) { - var sortBy = sortBys[i]; + for ( var i=0; i < sortBys.length; i++ ) { + var sortBy = sortBys[ i ]; var a = itemA.sortData[ sortBy ]; var b = itemB.sortData[ sortBy ]; if ( a > b || a < b ) { @@ -467,7 +467,7 @@ var trim = String.prototype.trim ? this._mode()._resetLayout(); }; - proto._getItemLayoutPosition = function( item ) { + proto._getItemLayoutPosition = function( item ) { return this._mode()._getItemLayoutPosition( item ); }; @@ -538,19 +538,19 @@ var trim = String.prototype.trim ? var i, item; var len = items.length; for ( i=0; i < len; i++ ) { - item = items[i]; + item = items[ i ]; this.element.appendChild( item.element ); } // filter new stuff var filteredInsertItems = this._filter( items ).matches; // set flag for ( i=0; i < len; i++ ) { - items[i].isLayoutInstant = true; + items[ i ].isLayoutInstant = true; } this.arrange(); // reset flag for ( i=0; i < len; i++ ) { - delete items[i].isLayoutInstant; + delete items[ i ].isLayoutInstant; } this.reveal( filteredInsertItems ); }; @@ -565,7 +565,7 @@ var trim = String.prototype.trim ? var len = removeItems && removeItems.length; // remove elems from filteredItems for ( var i=0; len && i < len; i++ ) { - var item = removeItems[i]; + var item = removeItems[ i ]; // remove item from collection utils.removeFrom( this.filteredItems, item ); } @@ -574,7 +574,7 @@ var trim = String.prototype.trim ? proto.shuffle = function() { // update random sortData for ( var i=0; i < this.items.length; i++ ) { - var item = this.items[i]; + var item = this.items[ i ]; item.sortData.random = Math.random(); } this.options.sortBy = 'random'; diff --git a/js/item.js b/js/item.js index dafd26c..9531608 100644 --- a/js/item.js +++ b/js/item.js @@ -14,7 +14,7 @@ } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( - require('outlayer') + require( 'outlayer' ) ); } else { // browser global @@ -51,7 +51,7 @@ proto.updateSortData = function() { // default sorters this.sortData.id = this.id; // for backward compatibility - this.sortData['original-order'] = this.id; + this.sortData[ 'original-order' ] = this.id; this.sortData.random = Math.random(); // go thru getSortData obj and apply the sorters var getSortData = this.layout.options.getSortData; diff --git a/js/layout-mode.js b/js/layout-mode.js index 2d28625..4219e14 100644 --- a/js/layout-mode.js +++ b/js/layout-mode.js @@ -15,8 +15,8 @@ } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( - require('get-size'), - require('outlayer') + require( 'get-size' ), + require( 'outlayer' ) ); } else { // browser global @@ -112,7 +112,7 @@ }; proto.getFirstItemSize = function() { - var firstItem = this.isotope.filteredItems[0]; + var firstItem = this.isotope.filteredItems[ 0 ]; return firstItem && firstItem.element && getSize( firstItem.element ); }; diff --git a/js/layout-modes/fit-rows.js b/js/layout-modes/fit-rows.js index d90f068..d83d795 100644 --- a/js/layout-modes/fit-rows.js +++ b/js/layout-modes/fit-rows.js @@ -14,7 +14,7 @@ } else if ( typeof exports == 'object' ) { // CommonJS module.exports = factory( - require('../layout-mode') + require( '../layout-mode' ) ); } else { // browser global @@ -26,7 +26,7 @@ }( window, function factory( LayoutMode ) { 'use strict'; -var FitRows = LayoutMode.create('fitRows'); +var FitRows = LayoutMode.create( 'fitRows' ); var proto = FitRows.prototype; diff --git a/js/layout-modes/masonry.js b/js/layout-modes/masonry.js index 099fa77..7e6b9ff 100644 --- a/js/layout-modes/masonry.js +++ b/js/layout-modes/masonry.js @@ -17,8 +17,8 @@ } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( - require('../layout-mode'), - require('masonry-layout') + require( '../layout-mode' ), + require( 'masonry-layout' ) ); } else { // browser global @@ -34,7 +34,7 @@ // -------------------------- masonryDefinition -------------------------- // // create an Outlayer layout class - var MasonryMode = LayoutMode.create('masonry'); + var MasonryMode = LayoutMode.create( 'masonry' ); var proto = MasonryMode.prototype; diff --git a/js/layout-modes/vertical.js b/js/layout-modes/vertical.js index ce57016..413c3cb 100644 --- a/js/layout-modes/vertical.js +++ b/js/layout-modes/vertical.js @@ -14,7 +14,7 @@ } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( - require('../layout-mode') + require( '../layout-mode' ) ); } else { // browser global