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'] : ''), {
locations: locations,
template: template + '.tpl',
url: url
url: url,
isMobile: utils.isMobile()
}, function(renderedAreas) {
for (var x=0; x<renderedAreas.length; ++x) {
var renderedWidgets = renderedAreas[x].widgets,

@ -117,6 +117,7 @@ apiController.renderWidgets = function(req, res, next) {
template: areas.template,
url: areas.url,
locations: areas.locations,
isMobile: req.query.isMobile === 'true'
},
req,
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";
var async = require('async'),
plugins = require('../plugins');
var fs = require('fs');
var path = require('path');
var async = require('async');
var plugins = require('../plugins');
var admin = {};
@ -22,6 +23,9 @@ admin.get = function(callback) {
},
widgets: function(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) {
if (err) {
@ -34,17 +38,14 @@ admin.get = function(callback) {
area.data = areaData;
next(err);
});
}, function(err) {
if (err) {
return callback(err);
}
for (var w in widgetData.widgets) {
if (widgetData.widgets.hasOwnProperty(w)) {
// if this gets anymore complicated, it needs to be a template
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>";
}
}
widgetData.widgets.forEach(function(w) {
w.content += widgetData.adminTemplate;
});
var templates = [],
list = {}, index = 0;

@ -1,12 +1,12 @@
"use strict";
var async = require('async'),
winston = require('winston'),
templates = require('templates.js'),
var async = require('async');
var winston = require('winston');
var templates = require('templates.js');
plugins = require('../plugins'),
translator = require('../../public/src/modules/translator'),
db = require('../database');
var plugins = require('../plugins');
var translator = require('../../public/src/modules/translator');
var db = require('../database');
var widgets = {};
@ -30,7 +30,10 @@ widgets.render = function(uid, area, req, res, callback) {
}
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();
}

Loading…
Cancel
Save