/* * Ideal Image Slider: Captions Extension v1.0.1 * * By Gilbert Pellegrom * http://gilbert.pellegrom.me * * Copyright (C) 2014 Dev7studios * https://raw.githubusercontent.com/gilbitron/Ideal-Image-Slider/master/LICENSE */ (function(IIS) { "use strict"; IIS.Slider.prototype.addCaptions = function() { IIS._addClass(this._attributes.container, 'iis-has-captions'); Array.prototype.forEach.call(this._attributes.slides, function(slide, i) { var caption = document.createElement('div'); IIS._addClass(caption, 'iis-caption'); var captionContent = ''; if (slide.getAttribute('title')) { captionContent += '
' + slide.getAttribute('title') + '
'; } if (slide.getAttribute('data-caption')) { var dataCaption = slide.getAttribute('data-caption'); if (dataCaption.substring(0, 1) == '#' || dataCaption.substring(0, 1) == '.') { var external = document.querySelector(dataCaption); if (external) { captionContent += '
' + external.innerHTML + '
'; } } else { captionContent += '
' + slide.getAttribute('data-caption') + '
'; } } else { if (slide.innerHTML) { captionContent += '
' + slide.innerHTML + '
'; } } slide.innerHTML = ''; if (captionContent) { caption.innerHTML = captionContent; slide.appendChild(caption); } }.bind(this)); }; return IIS; })(IdealImageSlider);