Skip to content

Commit

Permalink
better code layout
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jul 5, 2018
1 parent 9067e77 commit acf42b7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
20 changes: 10 additions & 10 deletions src/js/base/ripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,12 @@ ripe.Ripe.prototype.setParts = function(update, noUpdate, options) {
update = this._partsList(update);
}

if (!noUpdate) {
this.trigger("pre_parts", this.parts, options);
}

for (var index = 0; index < update.length; index++) {
var part = update[index];
this._setPart(part[0], part[1], part[2]);
}

if (noUpdate) {
return;
return this._setParts(update);
}

this.trigger("pre_parts", this.parts, options);
this._setParts(update);
this.update();
this.trigger("parts", this.parts, options);
this.trigger("post_parts", this.parts, options);
Expand Down Expand Up @@ -367,6 +360,13 @@ ripe.Ripe.prototype._setPart = function(part, material, color) {
this.trigger("post_part", part, value);
};

ripe.Ripe.prototype._setParts = function(update) {
for (var index = 0; index < update.length; index++) {
var part = update[index];
this._setPart(part[0], part[1], part[2]);
}
};

ripe.Ripe.prototype._partsList = function(parts) {
parts = parts || this.parts;
var partsList = [];
Expand Down
8 changes: 3 additions & 5 deletions src/js/ripe-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/js/ripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,12 @@ ripe.Ripe.prototype.setParts = function(update, noUpdate, options) {
update = this._partsList(update);
}

if (!noUpdate) {
this.trigger("pre_parts", this.parts, options);
}

for (var index = 0; index < update.length; index++) {
var part = update[index];
this._setPart(part[0], part[1], part[2]);
}

if (noUpdate) {
return;
return this._setParts(update);
}

this.trigger("pre_parts", this.parts, options);
this._setParts(update);
this.update();
this.trigger("parts", this.parts, options);
this.trigger("post_parts", this.parts, options);
Expand Down Expand Up @@ -612,6 +605,13 @@ ripe.Ripe.prototype._setPart = function(part, material, color) {
this.trigger("post_part", part, value);
};

ripe.Ripe.prototype._setParts = function(update) {
for (var index = 0; index < update.length; index++) {
var part = update[index];
this._setPart(part[0], part[1], part[2]);
}
};

ripe.Ripe.prototype._partsList = function(parts) {
parts = parts || this.parts;
var partsList = [];
Expand Down
20 changes: 10 additions & 10 deletions src/python/ripe_demo/static/js/ripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,12 @@ ripe.Ripe.prototype.setParts = function(update, noUpdate, options) {
update = this._partsList(update);
}

if (!noUpdate) {
this.trigger("pre_parts", this.parts, options);
}

for (var index = 0; index < update.length; index++) {
var part = update[index];
this._setPart(part[0], part[1], part[2]);
}

if (noUpdate) {
return;
return this._setParts(update);
}

this.trigger("pre_parts", this.parts, options);
this._setParts(update);
this.update();
this.trigger("parts", this.parts, options);
this.trigger("post_parts", this.parts, options);
Expand Down Expand Up @@ -612,6 +605,13 @@ ripe.Ripe.prototype._setPart = function(part, material, color) {
this.trigger("post_part", part, value);
};

ripe.Ripe.prototype._setParts = function(update) {
for (var index = 0; index < update.length; index++) {
var part = update[index];
this._setPart(part[0], part[1], part[2]);
}
};

ripe.Ripe.prototype._partsList = function(parts) {
parts = parts || this.parts;
var partsList = [];
Expand Down

0 comments on commit acf42b7

Please sign in to comment.