Browse Source

Update code style to be consistent throughout

pull/1328/head
Stephen O'Loughlin 7 years ago
parent
commit
5da622b0d8
  1. 54
      js/isotope.js
  2. 4
      js/item.js
  3. 6
      js/layout-mode.js
  4. 4
      js/layout-modes/fit-rows.js
  5. 6
      js/layout-modes/masonry.js
  6. 2
      js/layout-modes/vertical.js

54
js/isotope.js

@ -32,16 +32,16 @@
// CommonJS // CommonJS
module.exports = factory( module.exports = factory(
window, window,
require('outlayer'), require( 'outlayer' ),
require('get-size'), require( 'get-size' ),
require('desandro-matches-selector'), require( 'desandro-matches-selector' ),
require('fizzy-ui-utils'), require( 'fizzy-ui-utils' ),
require('./item'), require( './item' ),
require('./layout-mode'), require( './layout-mode' ),
// include default layout modes // include default layout modes
require('./layout-modes/masonry'), require( './layout-modes/masonry' ),
require('./layout-modes/fit-rows'), require( './layout-modes/fit-rows' ),
require('./layout-modes/vertical') require( './layout-modes/vertical' )
); );
} else { } else {
// browser global // browser global
@ -120,7 +120,7 @@ var trim = String.prototype.trim ?
var items = Outlayer.prototype._itemize.apply( this, arguments ); var items = Outlayer.prototype._itemize.apply( this, arguments );
// assign ID for original-order // assign ID for original-order
for ( var i=0; i < items.length; i++ ) { for ( var i=0; i < items.length; i++ ) {
var item = items[i]; var item = items[ i ];
item.id = this.itemGUID++; item.id = this.itemGUID++;
} }
this._updateItemsSortData( items ); this._updateItemsSortData( items );
@ -144,7 +144,7 @@ var trim = String.prototype.trim ?
proto.layout = function() { proto.layout = function() {
// if first time doing layout, do all magic // if first time doing layout, do all magic
if ( !this._isLayoutInited && this._getOption('initLayout') ) { if ( !this._isLayoutInited && this._getOption( 'initLayout' ) ) {
this.arrange(); this.arrange();
return; return;
} }
@ -198,7 +198,7 @@ var trim = String.prototype.trim ?
// Don't animate/transition first layout // Don't animate/transition first layout
// Or don't animate/transition other layouts // Or don't animate/transition other layouts
proto._getIsInstant = function() { proto._getIsInstant = function() {
var isLayoutInstant = this._getOption('layoutInstant'); var isLayoutInstant = this._getOption( 'layoutInstant' );
var isInstant = isLayoutInstant !== undefined ? isLayoutInstant : var isInstant = isLayoutInstant !== undefined ? isLayoutInstant :
!this._isLayoutInited; !this._isLayoutInited;
this._isInstant = isInstant; this._isInstant = isInstant;
@ -243,7 +243,7 @@ var trim = String.prototype.trim ?
// test each item // test each item
for ( var i=0; i < items.length; i++ ) { for ( var i=0; i < items.length; i++ ) {
var item = items[i]; var item = items[ i ];
if ( item.isIgnored ) { if ( item.isIgnored ) {
continue; continue;
} }
@ -328,7 +328,7 @@ var trim = String.prototype.trim ?
var len = items && items.length; var len = items && items.length;
for ( var i=0; len && i < len; i++ ) { for ( var i=0; len && i < len; i++ ) {
var item = items[i]; var item = items[ i ];
item.updateSortData(); item.updateSortData();
} }
}; };
@ -349,14 +349,14 @@ var trim = String.prototype.trim ?
return sorter; return sorter;
} }
// parse the sorter string // parse the sorter string
var args = trim( sorter ).split(' '); var args = trim( sorter ).split( ' ' );
var query = args[0]; var query = args[ 0 ];
// check if query looks like [an-attribute] // check if query looks like [an-attribute]
var attrMatch = query.match( /^\[(.+)\]$/ ); var attrMatch = query.match( /^\[(.+)\]$/ );
var attr = attrMatch && attrMatch[1]; var attr = attrMatch && attrMatch[ 1 ];
var getValue = getValueGetter( attr, query ); var getValue = getValueGetter( attr, query );
// use second argument as a parser // 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 // parse the value, if there was a parser
sorter = parser ? function( elem ) { sorter = parser ? function( elem ) {
return elem && parser( getValue( elem ) ); return elem && parser( getValue( elem ) );
@ -419,7 +419,7 @@ var trim = String.prototype.trim ?
// check if sortBys is same as start of sortHistory // check if sortBys is same as start of sortHistory
proto._getIsSameSortBy = function( sortBys ) { proto._getIsSameSortBy = function( sortBys ) {
for ( var i=0; i < sortBys.length; i++ ) { for ( var i=0; i < sortBys.length; i++ ) {
if ( sortBys[i] != this.sortHistory[i] ) { if ( sortBys[ i ] != this.sortHistory[ i ] ) {
return false; return false;
} }
} }
@ -430,8 +430,8 @@ var trim = String.prototype.trim ?
function getItemSorter( sortBys, sortAsc ) { function getItemSorter( sortBys, sortAsc ) {
return function sorter( itemA, itemB ) { return function sorter( itemA, itemB ) {
// cycle through all sortKeys // cycle through all sortKeys
for ( var i = 0; i < sortBys.length; i++ ) { for ( var i=0; i < sortBys.length; i++ ) {
var sortBy = sortBys[i]; var sortBy = sortBys[ i ];
var a = itemA.sortData[ sortBy ]; var a = itemA.sortData[ sortBy ];
var b = itemB.sortData[ sortBy ]; var b = itemB.sortData[ sortBy ];
if ( a > b || a < b ) { if ( a > b || a < b ) {
@ -467,7 +467,7 @@ var trim = String.prototype.trim ?
this._mode()._resetLayout(); this._mode()._resetLayout();
}; };
proto._getItemLayoutPosition = function( item ) { proto._getItemLayoutPosition = function( item ) {
return this._mode()._getItemLayoutPosition( item ); return this._mode()._getItemLayoutPosition( item );
}; };
@ -538,19 +538,19 @@ var trim = String.prototype.trim ?
var i, item; var i, item;
var len = items.length; var len = items.length;
for ( i=0; i < len; i++ ) { for ( i=0; i < len; i++ ) {
item = items[i]; item = items[ i ];
this.element.appendChild( item.element ); this.element.appendChild( item.element );
} }
// filter new stuff // filter new stuff
var filteredInsertItems = this._filter( items ).matches; var filteredInsertItems = this._filter( items ).matches;
// set flag // set flag
for ( i=0; i < len; i++ ) { for ( i=0; i < len; i++ ) {
items[i].isLayoutInstant = true; items[ i ].isLayoutInstant = true;
} }
this.arrange(); this.arrange();
// reset flag // reset flag
for ( i=0; i < len; i++ ) { for ( i=0; i < len; i++ ) {
delete items[i].isLayoutInstant; delete items[ i ].isLayoutInstant;
} }
this.reveal( filteredInsertItems ); this.reveal( filteredInsertItems );
}; };
@ -565,7 +565,7 @@ var trim = String.prototype.trim ?
var len = removeItems && removeItems.length; var len = removeItems && removeItems.length;
// remove elems from filteredItems // remove elems from filteredItems
for ( var i=0; len && i < len; i++ ) { for ( var i=0; len && i < len; i++ ) {
var item = removeItems[i]; var item = removeItems[ i ];
// remove item from collection // remove item from collection
utils.removeFrom( this.filteredItems, item ); utils.removeFrom( this.filteredItems, item );
} }
@ -574,7 +574,7 @@ var trim = String.prototype.trim ?
proto.shuffle = function() { proto.shuffle = function() {
// update random sortData // update random sortData
for ( var i=0; i < this.items.length; i++ ) { for ( var i=0; i < this.items.length; i++ ) {
var item = this.items[i]; var item = this.items[ i ];
item.sortData.random = Math.random(); item.sortData.random = Math.random();
} }
this.options.sortBy = 'random'; this.options.sortBy = 'random';

4
js/item.js

@ -14,7 +14,7 @@
} else if ( typeof module == 'object' && module.exports ) { } else if ( typeof module == 'object' && module.exports ) {
// CommonJS // CommonJS
module.exports = factory( module.exports = factory(
require('outlayer') require( 'outlayer' )
); );
} else { } else {
// browser global // browser global
@ -51,7 +51,7 @@ proto.updateSortData = function() {
// default sorters // default sorters
this.sortData.id = this.id; this.sortData.id = this.id;
// for backward compatibility // for backward compatibility
this.sortData['original-order'] = this.id; this.sortData[ 'original-order' ] = this.id;
this.sortData.random = Math.random(); this.sortData.random = Math.random();
// go thru getSortData obj and apply the sorters // go thru getSortData obj and apply the sorters
var getSortData = this.layout.options.getSortData; var getSortData = this.layout.options.getSortData;

6
js/layout-mode.js

@ -15,8 +15,8 @@
} else if ( typeof module == 'object' && module.exports ) { } else if ( typeof module == 'object' && module.exports ) {
// CommonJS // CommonJS
module.exports = factory( module.exports = factory(
require('get-size'), require( 'get-size' ),
require('outlayer') require( 'outlayer' )
); );
} else { } else {
// browser global // browser global
@ -112,7 +112,7 @@
}; };
proto.getFirstItemSize = function() { proto.getFirstItemSize = function() {
var firstItem = this.isotope.filteredItems[0]; var firstItem = this.isotope.filteredItems[ 0 ];
return firstItem && firstItem.element && getSize( firstItem.element ); return firstItem && firstItem.element && getSize( firstItem.element );
}; };

4
js/layout-modes/fit-rows.js

@ -14,7 +14,7 @@
} else if ( typeof exports == 'object' ) { } else if ( typeof exports == 'object' ) {
// CommonJS // CommonJS
module.exports = factory( module.exports = factory(
require('../layout-mode') require( '../layout-mode' )
); );
} else { } else {
// browser global // browser global
@ -26,7 +26,7 @@
}( window, function factory( LayoutMode ) { }( window, function factory( LayoutMode ) {
'use strict'; 'use strict';
var FitRows = LayoutMode.create('fitRows'); var FitRows = LayoutMode.create( 'fitRows' );
var proto = FitRows.prototype; var proto = FitRows.prototype;

6
js/layout-modes/masonry.js

@ -17,8 +17,8 @@
} else if ( typeof module == 'object' && module.exports ) { } else if ( typeof module == 'object' && module.exports ) {
// CommonJS // CommonJS
module.exports = factory( module.exports = factory(
require('../layout-mode'), require( '../layout-mode' ),
require('masonry-layout') require( 'masonry-layout' )
); );
} else { } else {
// browser global // browser global
@ -34,7 +34,7 @@
// -------------------------- masonryDefinition -------------------------- // // -------------------------- masonryDefinition -------------------------- //
// create an Outlayer layout class // create an Outlayer layout class
var MasonryMode = LayoutMode.create('masonry'); var MasonryMode = LayoutMode.create( 'masonry' );
var proto = MasonryMode.prototype; var proto = MasonryMode.prototype;

2
js/layout-modes/vertical.js

@ -14,7 +14,7 @@
} else if ( typeof module == 'object' && module.exports ) { } else if ( typeof module == 'object' && module.exports ) {
// CommonJS // CommonJS
module.exports = factory( module.exports = factory(
require('../layout-mode') require( '../layout-mode' )
); );
} else { } else {
// browser global // browser global

Loading…
Cancel
Save