diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index 761a57f423..5b7c3a13e1 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -54,6 +54,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { $('#widgets .widget-area').sortable({ update: function (event, ui) { + createDatePicker(ui.item); appendToggle(ui.item); }, connectWith: "div" @@ -154,6 +155,15 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { }); } + function createDatePicker(el) { + var currentYear = new Date().getFullYear(); + el.find('.date-selector').datepicker({ + changeMonth: true, + changeYear: true, + yearRange: currentYear + ':' + (currentYear + 100) + }); + } + function appendToggle(el) { if (!el.hasClass('block')) { el.addClass('block').css('width', '').css('height', '') @@ -209,6 +219,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { widgetArea.append(populateWidget(widgetEl, widgetData.data)); appendToggle(widgetEl); + createDatePicker(widgetEl); } } diff --git a/public/src/widgets.js b/public/src/widgets.js index 8d4eb10e1f..46023fad15 100644 --- a/public/src/widgets.js +++ b/public/src/widgets.js @@ -33,6 +33,7 @@ locations: widgetLocations, template: template + '.tpl', url: url, + cid: ajaxify.data.cid, isMobile: utils.isMobile() }, function (renderedAreas) { for (var x = 0; x < renderedAreas.length; ++x) { diff --git a/src/controllers/api.js b/src/controllers/api.js index f9e317cee7..1bbf3962c8 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -109,22 +109,17 @@ apiController.getConfig = function (req, res, next) { apiController.renderWidgets = function (req, res, next) { - var areas = { - template: req.query.template, - locations: req.query.locations, - url: req.query.url - }; - - if (!areas.template || !areas.locations) { + if (!req.query.template || !req.query.locations) { return res.status(200).json({}); } widgets.render(req.uid, { - template: areas.template, - url: areas.url, - locations: areas.locations, - isMobile: req.query.isMobile === 'true' + template: req.query.template, + url: req.query.url, + locations: req.query.locations, + isMobile: req.query.isMobile === 'true', + cid: req.query.cid }, req, res,