v1.18.x
barisusakli 9 years ago
parent e791ed9002
commit c758f59014

@ -40,7 +40,8 @@
$.get(RELATIVE_PATH + '/api/widgets/render' + (config['cache-buster'] ? '?v=' + config['cache-buster'] : ''), { $.get(RELATIVE_PATH + '/api/widgets/render' + (config['cache-buster'] ? '?v=' + config['cache-buster'] : ''), {
locations: locations, locations: locations,
template: template + '.tpl', template: template + '.tpl',
url: url url: url,
isMobile: utils.isMobile()
}, function(renderedAreas) { }, function(renderedAreas) {
for (var x=0; x<renderedAreas.length; ++x) { for (var x=0; x<renderedAreas.length; ++x) {
var renderedWidgets = renderedAreas[x].widgets, var renderedWidgets = renderedAreas[x].widgets,

@ -117,6 +117,7 @@ apiController.renderWidgets = function(req, res, next) {
template: areas.template, template: areas.template,
url: areas.url, url: areas.url,
locations: areas.locations, locations: areas.locations,
isMobile: req.query.isMobile === 'true'
}, },
req, req,
res, res,

@ -0,0 +1,18 @@
<br />
<label>Title:</label>
<input type="text" class="form-control" name="title" placeholder="Title (only shown on some containers)" /><br />
<label>Container:</label>
<textarea rows="4" class="form-control container-html" name="container" placeholder="Drag and drop a container or enter HTML here."></textarea>
<div class="checkbox">
<label><input name="hide-guests" type="checkbox"> Hide from anonymous users?</label>
</div>
<div class="checkbox">
<label><input name="hide-registered" type="checkbox"> Hide from registered users?</input></label>
</div>
<div class="checkbox">
<label><input name="hide-mobile" type="checkbox"> Hide on mobile?</input></label>
</div>

@ -1,8 +1,9 @@
"use strict"; "use strict";
var fs = require('fs');
var async = require('async'), var path = require('path');
plugins = require('../plugins'); var async = require('async');
var plugins = require('../plugins');
var admin = {}; var admin = {};
@ -22,6 +23,9 @@ admin.get = function(callback) {
}, },
widgets: function(next) { widgets: function(next) {
plugins.fireHook('filter:widgets.getWidgets', [], next); plugins.fireHook('filter:widgets.getWidgets', [], next);
},
adminTemplate: function(next) {
fs.readFile(path.resolve(__dirname, '../../public/templates/admin/partials/widget-settings.tpl'), 'utf8', next);
} }
}, function(err, widgetData) { }, function(err, widgetData) {
if (err) { if (err) {
@ -34,17 +38,14 @@ admin.get = function(callback) {
area.data = areaData; area.data = areaData;
next(err); next(err);
}); });
}, function(err) { }, function(err) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
for (var w in widgetData.widgets) {
if (widgetData.widgets.hasOwnProperty(w)) { widgetData.widgets.forEach(function(w) {
// if this gets anymore complicated, it needs to be a template w.content += widgetData.adminTemplate;
widgetData.widgets[w].content += "<br /><label>Title:</label><input type=\"text\" class=\"form-control\" name=\"title\" placeholder=\"Title (only shown on some containers)\" /><br /><label>Container:</label><textarea rows=\"4\" class=\"form-control container-html\" name=\"container\" placeholder=\"Drag and drop a container or enter HTML here.\"></textarea><div class=\"checkbox\"><label><input name=\"hide-guests\" type=\"checkbox\"> Hide from anonymous users?</label></div><div class=\"checkbox\"><label><input name=\"hide-registered\" type=\"checkbox\"> Hide from registered users?</input></label></div>"; });
}
}
var templates = [], var templates = [],
list = {}, index = 0; list = {}, index = 0;

@ -1,12 +1,12 @@
"use strict"; "use strict";
var async = require('async'), var async = require('async');
winston = require('winston'), var winston = require('winston');
templates = require('templates.js'), var templates = require('templates.js');
plugins = require('../plugins'), var plugins = require('../plugins');
translator = require('../../public/src/modules/translator'), var translator = require('../../public/src/modules/translator');
db = require('../database'); var db = require('../database');
var widgets = {}; var widgets = {};
@ -30,7 +30,10 @@ widgets.render = function(uid, area, req, res, callback) {
} }
async.map(widgetsByLocation[location], function(widget, next) { async.map(widgetsByLocation[location], function(widget, next) {
if (!widget || !widget.data || (!!widget.data['hide-registered'] && uid !== 0) || (!!widget.data['hide-guests'] && uid === 0)) { if (!widget || !widget.data ||
(!!widget.data['hide-registered'] && uid !== 0) ||
(!!widget.data['hide-guests'] && uid === 0) ||
(!!widget.data['hide-mobile'] && area.isMobile)) {
return next(); return next();
} }

Loading…
Cancel
Save