module-and-template-store/app/assets/javascripts/plugin/app.js

32 lines
1.2 KiB
JavaScript

$(function() {
details_ShowMore = function () {
var _h = 0;
$('.text-body').each(function() {
$(this).children('*').each(function() {
_h += $(this).outerHeight(true);
});
_h > $(this).outerHeight(true) ? $(this).siblings('.more-details').show() : '';
});
$('.details-section').on('click', '.more-details', function(e) {
$(this).closest('.details-section').addClass('open');
e.preventDefault();
});
};
details_screenshots = function() {
var _imgSrc = [],
$screenshotsView = $('<div class="screenshots-view" />');
$('.screenshots-list img').each(function(i) {
i == 0 ? $(this).closest('.screenshots-img').addClass('active') : '';
_imgSrc.push($(this).attr('src'));
});
$('.screenshots-list').on('click', '.screenshots-img', function() {
$(this).addClass('active').siblings().removeClass('active');
$('.screenshots-view img').addClass('hide').eq($(this).index()).removeClass('hide');
});
$.map(_imgSrc, function(v, i) {
$screenshotsView.append('<img src="' + v + '" class="' + (i > 0 ? 'hide' : '') + '" />');
})
$('.screenshots-groups').prepend($screenshotsView);
};
details_screenshots();
})