CoreFiles by mySites.guru
admin-modules-modal.js49 lines, 1,985 bytes, from Joomla_3.7.1-Stable-Full_Package.zip
Raw History Compare with 3.7.0
md5
ca1ecee4eecbf49909dc98a6ea25b34a
sha1
5b05c80240a74504ffc47711388b0206c5304abe
sha256
3ae5aaae6b8d95411a118e7ae3953dfebb66e1dcdd4c27dec24cd5a6ff4614e7
/**
 * @copyright  Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

document.addEventListener('DOMContentLoaded', function() {
	"use strict";

	/** Get the elements **/
	var modulesLinks = document.querySelectorAll('.js-module-insert'), i,
		positionsLinks = document.querySelectorAll('.js-position-insert');

	/** Assign listener for click event (for single module insertion) **/
	for (i= 0; modulesLinks.length > i; i++) {
		modulesLinks[i].addEventListener('click', function(event) {
			event.preventDefault();
			var type = event.target.getAttribute('data-module'),
				name = event.target.getAttribute('data-title'),
				editor = event.target.getAttribute('data-editor');

			/** Use the API, if editor supports it **/
			if (window.parent.Joomla && window.parent.Joomla.editors && window.parent.Joomla.editors.instances && window.parent.Joomla.editors.instances.hasOwnProperty(editor)) {
				window.parent.Joomla.editors.instances[editor].replaceSelection("{loadmodule " + type + "," + name + "}")
			} else {
				window.parent.jInsertEditorText("{loadmodule " + type + "," + name + "}", editor);
			}

			window.parent.jModalClose();
		});
	}

	/** Assign listener for click event (for position insertion) **/
	for (i= 0; positionsLinks.length > i; i++) {
		positionsLinks[i].addEventListener('click', function(event) {
			event.preventDefault();
			var position = event.target.getAttribute('data-position'),
				editor = event.target.getAttribute('data-editor');

			/** Use the API, if editor supports it **/
			if (window.Joomla && window.Joomla.editors && Joomla.editors.instances && Joomla.editors.instances.hasOwnProperty(editor)) {
				Joomla.editors.instances[editor].replaceSelection("{loadposition " + position + "}")
			} else {
				window.parent.jInsertEditorText("{loadposition " + position + "}", editor);
			}

			window.parent.jModalClose();
		});
	}
});

The same content is in 30 releases, Joomla 3.7.0-beta4 to 3.8.3. See them all, or every version of this file.