Commit 960afe58 authored by Sven Franck's avatar Sven Franck

app: update dynamic content generation to handle popup and panels

parent 9e8b1d5e
...@@ -2620,9 +2620,11 @@ ...@@ -2620,9 +2620,11 @@
}; };
// TODO: remove, should be handled by content.set // TODO: remove, should be handled by content.set
// TODO: why is this not done on click, when we can get the href > element
// from the link attribute?
/** /**
* Load content into a dynamic element * Load content into a dynamic element
* @method generatePopupContents * @method generateDynamicContents
* @param {obj} object Action object (popupbeforeposition) * @param {obj} object Action object (popupbeforeposition)
*/ */
factory.util.generateDynamicContents = function (obj) { factory.util.generateDynamicContents = function (obj) {
...@@ -2640,6 +2642,10 @@ ...@@ -2640,6 +2642,10 @@
} else { } else {
element.setAttribute("data-state", reference); element.setAttribute("data-state", reference);
element.setAttribute("data-reference", reference); element.setAttribute("data-reference", reference);
// empty gadget and reload
// TODO: how to replace in javaScript?
element.innerHTML = "";
promises = []; promises = [];
// fetch content // fetch content
...@@ -2650,29 +2656,15 @@ ...@@ -2650,29 +2656,15 @@
"pass": undefined "pass": undefined
}) })
.then(function (reply) { .then(function (reply) {
element.setAttribute("data-reference", reference); return RSVP.resolve(app.content.set(reply, {}));
if (reply.children) {
for (i = 0; i < reply.children.length; i += 1) {
promises[i] = app.content.set(reply.children[i], {});
}
}
return RSVP.all(promises);
}) })
.then(function (content) { .then(function (content) {
fragment = document.createDocumentFragment();
for (j = 0; j < content.length; j += 1) {
fragment.appendChild(content[j]);
}
// translate // translate
if (i18n) { if (i18n) {
map.actions.translateNodeList(fragment); map.actions.translateNodeList(content);
} }
// empty gadget and reload
// TODO: how to replace in javaScript?
element.innerHTML = "";
// append // append
element.appendChild(fragment); element.appendChild(content);
}) })
.then(function () { .then(function () {
$el = $(element); $el = $(element);
...@@ -2683,6 +2675,7 @@ ...@@ -2683,6 +2675,7 @@
$el.popup("reposition", {"positionto": "window"}); $el.popup("reposition", {"positionto": "window"});
break; break;
} }
$el.enhanceWithin();
}) })
.fail(app.util.error); .fail(app.util.error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment