Skip to content

Commit

Permalink
Added check for jQuery and domready event listener, see #21
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Nov 18, 2015
1 parent 1c8b0c9 commit 2721611
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions templates/rsts_default.html5
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,21 @@

<script>
<?php if (version_compare(VERSION, '3.3', '>=')) { $this->block('script'); } ?>
(function($) {
(function() {

var slider = $('.mod_rocksolid_slider').last();
var sliderElement = [].slice.call(document.getElementsByClassName('mod_rocksolid_slider'), -1 )[0];

if (window.jQuery && jQuery.fn.rstSlider) {
init();
}
else {
document.addEventListener('DOMContentLoaded', init);
}

function init() {

var $ = jQuery;
var slider = $(sliderElement);

<?php if (version_compare(VERSION, '3.3', '>=')) { $this->block('script_bgvideo'); } ?>
slider.find('video[data-rsts-background], [data-rsts-type=video] video').each(function() {
Expand Down Expand Up @@ -271,6 +283,8 @@
});
<?php if (version_compare(VERSION, '3.3', '>=')) { $this->endblock(); } ?>

})(jQuery);
}

})();
<?php if (version_compare(VERSION, '3.3', '>=')) { $this->endblock(); } ?>
</script>

0 comments on commit 2721611

Please sign in to comment.