Skip to content

Instantly share code, notes, and snippets.

@lindleyw
Created March 15, 2018 11:40
Show Gist options
  • Save lindleyw/c69e511b4e40f89a42feeb0221b5dd7d to your computer and use it in GitHub Desktop.
Save lindleyw/c69e511b4e40f89a42feeb0221b5dd7d to your computer and use it in GitHub Desktop.
Mojo js embed test
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render(template => 'index');
};
app->start;
__DATA__
@@ index.html.ep
%= javascript '/jquery.v1.12.4.min.js'
%= javascript '/bootstrap.js'
%= javascript begin
function carouselNormalization() {
var items = $('#carousel-example-generic .item'), //grab all slides
heights = [], //create empty array to store height values
tallest; //create variable to make note of the tallest slide
if (items.length) {
function normalizeHeights() {
items.each(function() { //add heights to array
heights.push($(this).height());
});
tallest = Math.max.apply(null, heights); //cache largest value
items.each(function() {
$(this).css('min-height',tallest + 'px');
});
};
normalizeHeights();
$(window).on('resize orientationchange', function () {
tallest = 0, heights.length = 0; //reset vars
items.each(function() {
$(this).css('min-height','0'); //reset min-height
});
normalizeHeights(); //run it again
});
}
}
% end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment