- md5
- 60df22419bd269d5319ac71de27a21cf
- sha1
- 0b8c97fc75a49cce430b54152445c614d9eb2341
- sha256
- d9a545dc8bada6c776a09c69ee2fd38c8654003dfa7d9d0d660ba1d8560f0037
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* JCaption javascript behavior
*
* Used for displaying image captions
*
* @package Joomla
* @since 1.5
* @version 1.0
*/
Joomla = window.Joomla || {};
(function(Joomla) {
Joomla.JCaption = function(selector) {
var insertBefore = function(el, referenceNode) {
referenceNode.parentNode.insertBefore(el, referenceNode);
},
initialize = function(selector) {
var elements = document.querySelectorAll(selector);
for (var i = 0, count = elements.length; i < count; i++) {
createCaption(elements[i], selector);
}
},
createCaption = function(element, selector) {
var container, caption = element.getAttribute('title'),
width = element.getAttribute("width") || element.style.width,
align = element.getAttribute("align") || element.style.cssFloat || "none",
pEl = document.createElement('p'),
clearClass = selector.replace('.', '_').replace('#', '').replace(',', '').split(' ');
pEl.innerHTML = caption;
container = document.createElement('div');
clearClass.forEach(function(className) {
pEl.classList.add(className);
container.classList.add(className);
});
container.classList.add(align);
insertBefore(container, element);
if (caption !== "") {
container.appendChild(pEl);
}
container.style.cssFloat = align;
container.style.width = /px/.test(width) ? width : width + 'px';
container.appendChild(element);
};
initialize(selector);
};
document.addEventListener('DOMContentLoaded', function() {
if (Joomla.getOptions && typeof Joomla.getOptions === 'function' && Joomla.getOptions('js-image-caption')) {
if (Joomla.getOptions('js-image-caption').selector) {
new Joomla.JCaption(Joomla.getOptions('js-image-caption').selector);
}
}
});
})(Joomla);
No other release has this exact content. See every version of this file.