v1.18.x
psychobunny 11 years ago
parent ecbb05ccca
commit c6183f1a82

@ -93,25 +93,25 @@ var ajaxify = ajaxify || {};
templates.parse(tpl_url, data, function(template) {
translator.translate(template, function(translatedTemplate) {
$('#content').html(translatedTemplate);
ajaxify.widgets.render(tpl_url);
ajaxify.widgets.render(tpl_url, function() {
if (typeof callback === 'function') {
callback();
}
ajaxify.variables.parse();
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
app.processPage();
ajaxify.loadScript(tpl_url);
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
ajaxify.initialLoad = false;
if (typeof callback === 'function') {
callback();
}
app.refreshTitle(url);
$(window).trigger('action:ajaxify.end', {url: url});
});
app.processPage();
ajaxify.variables.parse();
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
ajaxify.initialLoad = false;
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
app.refreshTitle(url);
$(window).trigger('action:ajaxify.end', {url: url});
ajaxify.loadScript(tpl_url);
});
});
});

@ -33,10 +33,7 @@
function renderWidgets(location) {
var area = $('#content [widget-area="' + location + '"]');
socket.emit('widgets.render', {template: tpl_url + '.tpl', location: location}, function(err, renderedWidgets) {
if (err) {
return;
}
$.get(RELATIVE_PATH + '/api/widgets/render/' + tpl_url + '/' + location, function(renderedWidgets) {
var html = '';
for (var i=0; i<renderedWidgets.length; ++i) {

@ -3,7 +3,8 @@
var pkg = require('./../../package.json'),
meta = require('./../meta'),
user = require('./../user'),
plugins = require('./../plugins');
plugins = require('./../plugins'),
widgets = require('../widgets');
var apiController = {};
@ -77,4 +78,16 @@ apiController.getConfig = function(req, res, next) {
};
apiController.renderWidgets = function(req, res, next) {
var uid = req.user ? req.user.uid : 0,
area = {
template: req.params.template + '.tpl',
location: req.params.location
};
widgets.render(uid, area, function(err, data) {
res.json(200, data);
});
};
module.exports = apiController;

@ -184,6 +184,7 @@ module.exports = function(app, middleware, controllers) {
app.use('/api', router);
router.get('/config', controllers.api.getConfig);
router.get('/widgets/render/:template/:location', controllers.api.renderWidgets);
router.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);
router.get('/get_templates_listing', getTemplatesListing);

@ -9,7 +9,6 @@ var async = require('async'),
(function(Widgets) {
Widgets.render = function(uid, area, callback) {
if (!area.location || !area.template) {
callback({
@ -19,6 +18,7 @@ var async = require('async'),
var rendered = [];
async.parallel({
global: function(next) {
Widgets.getArea('global', area.location, next);

Loading…
Cancel
Save