mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	add cid to widgets.render
init date pickers in widgets ACP
This commit is contained in:
		| @@ -54,6 +54,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { | |||||||
|  |  | ||||||
| 		$('#widgets .widget-area').sortable({ | 		$('#widgets .widget-area').sortable({ | ||||||
| 			update: function (event, ui) { | 			update: function (event, ui) { | ||||||
|  | 				createDatePicker(ui.item); | ||||||
| 				appendToggle(ui.item); | 				appendToggle(ui.item); | ||||||
| 			}, | 			}, | ||||||
| 			connectWith: "div" | 			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) { | 	function appendToggle(el) { | ||||||
| 		if (!el.hasClass('block')) { | 		if (!el.hasClass('block')) { | ||||||
| 			el.addClass('block').css('width', '').css('height', '') | 			el.addClass('block').css('width', '').css('height', '') | ||||||
| @@ -209,6 +219,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { | |||||||
|  |  | ||||||
| 					widgetArea.append(populateWidget(widgetEl, widgetData.data)); | 					widgetArea.append(populateWidget(widgetEl, widgetData.data)); | ||||||
| 					appendToggle(widgetEl); | 					appendToggle(widgetEl); | ||||||
|  | 					createDatePicker(widgetEl); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,6 +33,7 @@ | |||||||
| 			locations: widgetLocations, | 			locations: widgetLocations, | ||||||
| 			template: template + '.tpl', | 			template: template + '.tpl', | ||||||
| 			url: url, | 			url: url, | ||||||
|  | 			cid: ajaxify.data.cid, | ||||||
| 			isMobile: utils.isMobile() | 			isMobile: utils.isMobile() | ||||||
| 		}, function (renderedAreas) { | 		}, function (renderedAreas) { | ||||||
| 			for (var x = 0; x < renderedAreas.length; ++x) { | 			for (var x = 0; x < renderedAreas.length; ++x) { | ||||||
|   | |||||||
| @@ -109,22 +109,17 @@ apiController.getConfig = function (req, res, next) { | |||||||
|  |  | ||||||
|  |  | ||||||
| apiController.renderWidgets = function (req, res, next) { | apiController.renderWidgets = function (req, res, next) { | ||||||
| 	var areas = { | 	if (!req.query.template || !req.query.locations) { | ||||||
| 		template: req.query.template, |  | ||||||
| 		locations: req.query.locations, |  | ||||||
| 		url: req.query.url |  | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	if (!areas.template || !areas.locations) { |  | ||||||
| 		return res.status(200).json({}); | 		return res.status(200).json({}); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	widgets.render(req.uid, | 	widgets.render(req.uid, | ||||||
| 		{ | 		{ | ||||||
| 			template: areas.template, | 			template: req.query.template, | ||||||
| 			url: areas.url, | 			url: req.query.url, | ||||||
| 			locations: areas.locations, | 			locations: req.query.locations, | ||||||
| 			isMobile: req.query.isMobile === 'true' | 			isMobile: req.query.isMobile === 'true', | ||||||
|  | 			cid: req.query.cid | ||||||
| 		}, | 		}, | ||||||
| 		req, | 		req, | ||||||
| 		res, | 		res, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user