<fim-prefix>Buttons: function (container) {
		let thisInstance = this;
		container.find('.sendMailBtn:not(.mailBtnActive)').each(function (e) {
			let sendButton = $(this);
			sendButton.addClass('mailBtnActive');
			sendButton.on('click', function (e) {
				e.stopPropagation();
				let url = sendButton.data('url');
				let popup = sendButton.data('popup');
				let toMail = sendButton.data('to');
				if (toMail) {
					url += '&to=' + encodeURIComponent(toMail);
				}
				if (app.getRecordId() && sendButton.data('record') !== app.getRecordId()) {
					url += '&crmModule=' + app.getModuleName() + '&crmRecord=' + app.getRecordId();
				}
				thisInstance.sendMailWindow(url, popup);
			});
		});
	},
	sendMailWindow: function (url, popup, postData) {
		if (popup) {
			let width = screen.width - 15;
			let height = screen.height - 150;
			let left = 0;
			let top = 30;
			let popupParams = 'width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
			if (postData == undefined) {
				window.open(
					url,
					'_blank',
					popupParams + ',resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,status=no,menubar=no'
				);
				return;
			}
			let form = $('<form/>', { action: 'index.php' });
			url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
				form.append($('<input>', { name: key, value: value }));
			});
			for (let i in postData) {
				form.append($('<input>', { name: i, value: JSON.stringify(postData[i]) }));
			}
			$('body').append(form);
			// BUG: CWE-352 Cross-Site Request Forgery (CSRF)
			// form.submit();
			// FIXED: 
<fim-middle>			form.trigger('submit');
		} else {
			window.location.href = url;
		}
	},
	registerWidgetsEvents: function () {
		let widgets = $('div.widgetContainer');
		widgets.on('shown.bs.collapse', function (<fix-suffix>e) {
			let widgetContainer = $(e.currentTarget);
			Vtiger_Index_Js.loadWidgets(widgetContainer);
			let key = widgetContainer.attr('id');
			app.cacheSet(key, 1);
		});
		widgets.on('hidden.bs.collapse', function (e) {
			let widgetContainer = $(e.currentTarget);
			let imageEle = widgetContainer.parent().find('.imageElement');
			let imagePath = imageEle.data('rightimage');
			imageEle.attr('src', imagePath);
			let key = widgetContainer.attr('id');
			app.cacheSet(key, 0);
		});
	},
	/**
	 * Function is used to load the sidebar widgets
	 * @param widgetContainer - widget container
	 * @param open - widget should be open or closed
	 */
	loadWidgets: function (widgetContainer, open) {
		let message = $('.loadingWidgetMsg').html();
		if (widgetContainer.find('.card-body').html().trim()) {
			let imageEle = widgetContainer.parent().find('.imageElement');
			let imagePath = imageEle.data('downimage');
			imageEle.attr('src', imagePath);
			widgetContainer.css('height', 'auto');
			retur<|endoftext|>