Skip to content

Commit

Permalink
Refactor addFwGrid
Browse files Browse the repository at this point in the history
with ES6
  • Loading branch information
eddiewentw committed Feb 5, 2017
1 parent 0f42186 commit dd9a6ed
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/fallwall.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,22 @@
/**
* directly append a new grid at the top of one column
*/
$.fn.addFwGrid = function( data, callback_func ) {
$.fn.addFwGrid = ( data, callbackFunction ) => {

if( typeof data == 'object' ) {
// Add a new grid
_appendGrids( data, 'up' );
if( typeof data !== 'object' ) {
throw new Error(`First parameter of addFwGrid(): ${data} must be Object`);
}

// Add a new grid
_appendGrids( data, 'up' );

if( callback_func ) {
if( typeof callback_func == 'function' )
callback_func();
else
console.error(callback_func+' is not a function');
if( callbackFunction ) {
if( typeof callbackFunction === 'function' ) {
callbackFunction();
}
else {
console.error(`${callbackFunction} is not a function`);
}
}
else {
throw new Error('First parameter of addFwGrid(): '+data+' must be Object');
}

};
Expand Down

0 comments on commit dd9a6ed

Please sign in to comment.