-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigurator.js
More file actions
24 lines (21 loc) · 882 Bytes
/
configurator.js
File metadata and controls
24 lines (21 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Configurator(model, options, configuration) {
if (!(this instanceof Configurator))
return new Configurator(model, options, configuration);
this.model = model;
this.options = options || {};
this.options.target = this.options.target || $("body");
this.render(configuration);
}
Configurator.prototype.render = function(configuration) {
var self = this;
configuration = configuration || new Configuration(this.model);
self.configuration = configuration;
var configurationRenderer = new ConfigurationRenderer(configuration, this.options.renderer);
configurationRenderer.renderTo(self.options.target, function() {
var newConfiguration = this.read(self.options.target);
if (newConfiguration.isValid())
self.render(newConfiguration);
else
self.render(this.configuration);
});
};