2013-03-15 12:28:43 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-releeph-preview-branch
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
|
|
|
* javelin-uri
|
2013-05-19 02:04:22 +02:00
|
|
|
* javelin-request
|
2013-03-15 12:28:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('releeph-preview-branch', function(config) {
|
|
|
|
|
|
|
|
var uri = JX.$U(config.uri);
|
2013-05-19 02:04:22 +02:00
|
|
|
for (var param_name in config.params.static) {
|
2013-03-15 12:28:43 +01:00
|
|
|
var value = config.params.static[param_name];
|
|
|
|
uri.setQueryParam(param_name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
var output = JX.$(config.outputID);
|
|
|
|
|
|
|
|
var dynamics = config.params.dynamic;
|
|
|
|
|
|
|
|
function renderPreview() {
|
2013-05-19 02:04:22 +02:00
|
|
|
for (var param_name in dynamics) {
|
2013-03-15 12:28:43 +01:00
|
|
|
var node_id = dynamics[param_name];
|
|
|
|
var input = JX.$(node_id);
|
|
|
|
uri.setQueryParam(param_name, input.value);
|
|
|
|
}
|
|
|
|
var request = new JX.Request(uri, function(response) {
|
|
|
|
JX.DOM.setContent(output, JX.$H(response.markup));
|
|
|
|
});
|
|
|
|
request.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
renderPreview();
|
|
|
|
|
2013-05-19 02:04:22 +02:00
|
|
|
for (var ii in dynamics) {
|
2013-03-15 12:28:43 +01:00
|
|
|
var node_id = dynamics[ii];
|
|
|
|
var input = JX.$(node_id);
|
|
|
|
JX.DOM.listen(
|
|
|
|
input,
|
|
|
|
['keyup', 'click', 'change'],
|
|
|
|
null,
|
2014-06-23 19:27:47 +02:00
|
|
|
function() {
|
2013-03-15 12:28:43 +01:00
|
|
|
renderPreview();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|