define(['jquery', 'lodash', 'api'], function($, _, _api) {
    'use strict';

    return {
        elementalParticle: function() {
            this.size = 1;
            this.isAlive = true;
            this.strength = 1;
            this.existence = 60;
            this.spin = true;
            this.speed = 1;
            this.countDown = _api.deadCowntDown(this);
            this.moves = function () {
                var self = this;
                if (_api.particlesCreated) {
                    var direction = _.sample(_api.movements);

                    if (!_.isUndefined(direction)) {
                        var worker = new Worker('core/movesWorker.js');
                        worker.addEventListener('message', function(e) {
                            if (!_.isUndefined(e.data)) {
                                switch(e.data) {
                                    case 'top':
                                        _api.moveTop(self);
                                        break;
                                    case 'left':
                                        _api.moveLeft(self);
                                        break;
                                    case 'bottom':
                                        _api.moveBottom(self);
                                        break;
                                    case 'right':
                                        _api.moveRight(self);
                                        break;
                                }
                            }
                        });
                        worker.postMessage({ 'direction': direction });
                    }
                }
            };

            return this;
        },
        tableConfig: function (height, width) {
            this.height = height;
            this.width = width;

            return this;
        },
        tableSizes: function (size) {
            var tableSize = null;
            switch (size) {
                case '100 x 300':
                    tableSize = this.tableConfig('100', '300');
                    this.createTable(tableSize);
                    break;
                case '300 x 600':
                    tableSize = this.tableConfig('300', '600');
                    this.createTable(tableSize);
                    break;
                case '600 x 800':
                    tableSize = this.tableConfig('600', '800');
                    this.createTable(tableSize);
                    break;
                case '800 x 1200':
                    tableSize = this.tableConfig('800', '1200');
                    this.createTable(tableSize);
                    break;
                case '1200 x 1400':
                    tableSize = this.tableConfig('1200', '1400');
                    this.createTable(tableSize);
                    break;
                case '1400 x 1600':
                    tableSize = this.tableConfig('1400', '1600');
                    this.createTable(tableSize);
                    break;
            }
        },
        numberOfParticles: function (data) {
            var num = null;
            if (data === 'Random') {
                num = _api.randomNumber(0, 1000);
                this.createParticles(num);
            } else {
                num = data;
                this.createParticles(num);
            }
        },
        createParticles: function (particles) {
            var dashboard = document.getElementById('tableDashboard');

            if (dashboard.childNodes[0].tagName === 'TABLE') {
                var self = this,
                    tableChilds = dashboard.childNodes[0].childNodes[0].childNodes,
                    trClasses = _api.returnClasses(tableChilds),
                    tdClasses = _api.returnClasses(tableChilds[0].childNodes),
                    i = 0;

                    for (i; i < particles; i++) {
                        var trRandom = _.sample(trClasses),
                            tdRandom = _.sample(tdClasses);

                            _.map(tableChilds, function (n) {
                                if (n.className === trRandom) {
                                    _.map(n.childNodes, function (d) {
                                        if (d.className === tdRandom) {
                                            d.className += ' elementalParticle';
                                            self.elementalParticle.call(d);
                                            _api.particlesCreated = true;
                                            d.moves();
                                        }
                                    });
                                }
                            });
                    }
            }
        },
        rowsRange: [],
        createTable: function(obj) {
            if (_.isObject(obj) && (!_.isUndefined(obj.width) && !_.isUndefined(obj.height))) {
                var dashboard = document.getElementById('tableDashboard'),
                    table = document.createElement('table'),
                    height = _.parseInt(obj.height),
                    width = _.parseInt(obj.width),
                    tableWidthRange = _.range(0, width, 10),
                    tableHeightRange = _.range(0, height, 10);

                this.rowsRange = _.map(tableHeightRange, function (n) {
                        var tds = _.map(tableWidthRange, function (d) {
                            return '<td name="td' + d + '" class="td'+ d +'" data="' + d + '"></td>';
                        });
                        return '<tr class="tr' + n + '" data="' + n + '">' + tds + '</tr>';
                    });

                    table.style.width = obj.width + 'px';
                    table.style.height = obj.height + 'px';

                    $(table).append(this.rowsRange);

                    if (_.isUndefined(dashboard.childNodes[0])) {
                        $(dashboard).append(table);
                    } else {
                        return;
                    }
            }
        }
    };
});

@@ -482,128 +482,8 @@
 ) %7B%0A
-                    var direction = _.sample(_api.movements);%0A%0A                    if (!_.isUndefined(direction)) %7B%0A    
     
@@ -639,28 +639,24 @@
             
-    
 if (!_.isUnd
@@ -669,28 +669,24 @@
 (e.data)) %7B%0A
-    
             
@@ -746,28 +746,24 @@
             
-    
 case 'top':%0A
@@ -790,36 +790,32 @@
                 
-   
- 
 _api.moveTop(sel
@@ -846,36 +846,32 @@
                 
-    
 break;%0A         
@@ -889,28 +889,24 @@
             
-   
- 
 case 'left':
@@ -902,28 +902,24 @@
 ase 'left':%0A
-    
             
@@ -995,39 +995,31 @@
             
-  
-  
 break;%0A
-    
             
@@ -1053,20 +1053,16 @@
 ottom':%0A
-    
         
@@ -1140,36 +1140,32 @@
                 
-    
 break;%0A         
@@ -1183,28 +1183,24 @@
             
- 
-   
 case 'right'
@@ -1197,28 +1197,24 @@
 se 'right':%0A
-    
             
@@ -1291,39 +1291,31 @@
             
-    
 break;%0A
-    
             
@@ -1352,34 +1352,26 @@
             
-    %7D%0A    
+%7D%0A
             
@@ -1398,28 +1398,24 @@
             
-    
 worker.postM
@@ -1425,58 +1425,10 @@
 age(
-%7B 'direction': direction %7D);%0A                    %7D
+);
 %0A   

Improve components.js