(function ($) {
'use strict';
jQuery.each(hugeit_gen_resp_lightbox_obj, function (index, value) {
if (value.indexOf('true') > -1 || value.indexOf('false') > -1)
hugeit_gen_resp_lightbox_obj[index] = value == "true";
});
function Lightbox(element, options) {
this.el = element;
this.$element = $(element);
this.$body = $('body');
this.objects = {};
this.lightboxModul = {};
this.$item = '';
this.$cont = '';
this.$items = this.$body.find('a.responsive_lightbox');
this.settings = $.extend({}, this.constructor.defaults, options);
this.init();
return this;
}
Lightbox.defaults = {
idPrefix: 'rwd-',
classPrefix: 'rwd-',
attrPrefix: 'data-',
slideAnimationType: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_slideAnimationType, /* effect_1 effect_2 effect_3
effect_4 effect_5 effect_6
effect_7 effect_8 effect_9 */
lightboxView: hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView, // view1, view2, view3, view4, view5, view6, view7
speed: hugeit_resp_lightbox_obj.hugeit_lightbox_speed_new,
width: hugeit_resp_lightbox_obj.hugeit_lightbox_width_new + '%',
height: hugeit_resp_lightbox_obj.hugeit_lightbox_height_new + '%',
videoMaxWidth: '700',
sizeFix: true, //not for option
overlayDuration: +hugeit_gen_resp_lightbox_obj.hugeit_lightbox_overlayDuration,
slideAnimation: true, //not for option
overlayClose: hugeit_resp_lightbox_obj.hugeit_lightbox_overlayClose_new,
loop: hugeit_resp_lightbox_obj.hugeit_lightbox_loop_new,
escKey: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_escKey_new,
keyPress: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_keyPress_new,
arrows: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_arrows,
mouseWheel: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_mouseWheel,
download: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_download,
showTitle: hugeit_resp_lightbox_obj.hugeit_lightbox_showTitle === 'true',
showDesc: hugeit_resp_lightbox_obj.hugeit_lightbox_showDesc === 'true',
showBorder: hugeit_resp_lightbox_obj.hugeit_lightbox_showBorder === 'true',
showCounter: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_showCounter,
defaultTitle: '', //some text
preload: 10, //not for option
showAfterLoad: true, //not for option
nextHtml: '', //not for option
prevHtml: '', //not for option
sequence_info: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_sequence_info,
sequenceInfo: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_sequenceInfo,
slideshow: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_slideshow_new,
slideshowAuto: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_slideshow_auto_new,
slideshowSpeed: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_slideshow_speed_new,
slideshowStart: '', //not for option
slideshowStop: '', //not for option
hideControlOnEnd: false, //not for option
watermark: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark,
socialSharing: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_socialSharing,
titlePos: hugeit_resp_lightbox_obj.hugeit_lightbox_title_pos,
fullwidth: hugeit_resp_lightbox_obj.hugeit_lightbox_fullwidth_effect === 'true',
zoomLogo: hugeit_resp_lightbox_obj.hugeit_lightbox_zoomlogo,
wURL: hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_link,
watermarkURL: hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_url,
wURLnewTab: hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_url_new_tab,
openCloseType: hugeit_resp_lightbox_obj.lightbox_open_close_effect,
thumbnail: hugeit_resp_lightbox_obj.hugeit_lightbox_thumbs === 'true',
share: {
facebookButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_facebookButton,
twitterButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_twitterButton,
googleplusButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_googleplusButton,
pinterestButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_pinterestButton,
linkedinButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_linkedinButton,
tumblrButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_tumblrButton,
redditButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_redditButton,
bufferButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_bufferButton,
diggButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_diggButton,
vkButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_vkButton,
yummlyButton: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_yummlyButton
}
};
Lightbox.prototype.init = function () {
var $object = this,
$hash,
$openCloseType;
switch(this.settings.openCloseType){
case '0':
$openCloseType = {
0: 'open_0',
1: 'close_0'
};
break;
case '1':
$openCloseType = {
0: 'open_1',
1: 'close_1'
};
break;
case '2':
$openCloseType = {
0: 'open_1_r',
1: 'close_1_r'
};
break;
case '3':
$openCloseType = {
0: 'open_2',
1: 'close_2'
};
break;
case '4':
$openCloseType = {
0: 'open_2_r',
1: 'close_2_r'
};
break;
case '5':
$openCloseType = {
0: 'open_3',
1: 'close_3'
};
break;
case '6':
$openCloseType = {
0: 'open_3_r',
1: 'close_3_r'
};
break;
case '7':
$openCloseType = {
0: 'open_4',
1: 'close_4'
};
break;
case '8':
$openCloseType = {
0: 'open_4_r',
1: 'close_4_r'
};
break;
case '9':
$openCloseType = {
0: 'open_5',
1: 'close_5'
};
break;
case '10':
$openCloseType = {
0: 'open_5_r',
1: 'close_5_r'
};
break;
}
if(this.settings.lightboxView !== 'view7'){
this.settings.openCloseType = $openCloseType;
} else {
this.settings.openCloseType = {0: 'open_1', 1: 'close_1'};
this.settings.slideAnimationType = 'effect_2';
}
$hash = window.location.hash;
($object.settings.watermark && $('.watermark').watermark());
if ($hash.indexOf('lightbox&') > 0) {
$object.index = parseInt($hash.split('&slide=')[1], 10) - 1;
$object.$body.addClass('rwd-share');
if (!$object.$body.hasClass('rwd-on')) {
setTimeout(function () {
$object.build($object.index);
}, 900);
$object.$body.addClass('rwd-on');
}
}
(($object.settings.preload > $object.$items.length) && ($object.settings.preload = $object.$items.length));
$object.$items.on('click.rwdcustom', function (event) {
event = event || window.event;
event.preventDefault ? event.preventDefault() : (event.returnValue = false);
$object.index = $object.$items.index(this);
if (!$object.$body.hasClass($object.settings.classPrefix + 'on')) {
$object.build($object.index);
$object.$body.addClass($object.settings.classPrefix + 'on');
}
});
$object.$body.on('click', function () {
$object.$_y_ = window.pageYOffset;
});
switch (this.settings.zoomLogo) {
case '1':
$object.$body.addClass('rwd-zoomGlass');
break;
case '2':
$object.$body.addClass('rwd-zoomHand');
break;
}
};
Lightbox.prototype.build = function (index) {
var $object = this;
$object.structure(index);
$object.lightboxModul['modul'] = new $.fn.lightbox.lightboxModul['modul']($object.el);
$object.slide(index, false, false);
($object.settings.keyPress && $object.addKeyEvents());
if ($object.$items.length > 1) {
$object.arrow();
($object.settings.mouseWheel && $object.mousewheel());
($object.settings.slideshow && $object.slideShow());
}
$object.counter();
$object.closeGallery();
$object.$cont.on('click.rwd-container', function () {
$object.$cont.removeClass($object.settings.classPrefix + 'hide-items');
});
$('.shareLook').on('click.rwd-container', function () {
$(this).css({'display': 'none'});
$('.rwd-share-buttons').css({'display': 'block'});
setTimeout(function(){
$('.shareLook').css({'display' : 'block'});
$('.rwd-share-buttons').css({'display' : 'none'});
}, 9000);
});
if(!this.settings.thumbnail){
$object.calculateDimensions(index);
} else {
setTimeout(function(){
$object.calculateDimensions(index);
}, 800);
}
if(this.settings.lightboxView === 'view7'){
setTimeout(function(){
$('.view7_share, .rwd-close-bar, .rwd-toolbar').css({
visibility: 'visible',
opacity: '1'
});
$object.calculateDimensions(index);
}, 1100);
jQuery('.rwd-close').hover(function(){
$('.rwd-cont').addClass('close_hover_on');
}, function(){
$('.rwd-cont').removeClass('close_hover_on');
});
var $w, $l;
if($('.rwd-container').width() > 768){
$('.rwd-view7-title').width($('.rwd-container').width() * 0.2 - 46);
$('.rwd-view7-desc').width($('.rwd-container').width() * 0.2 - 36);
setTimeout(function(){
$('.rwd-view7-desc').height($('.view7_inner').height() - 79);
}, 200);
$w = 256;
$l = $('.tool_bar .rwd-icon:not(.zoom_cont)').length;
if(hugeit_resp_lightbox_obj.hugeit_lightbox_zoom && hugeit_resp_lightbox_obj.hugeit_lightbox_zoomtype === '1'){
$('.zoom_cont').css({
'max-width': '220px'
});
$w = 220;
} else {
$('.zoom_cont').css({
'max-width': '145px'
});
$w = 145;
}
$('.tool_bar').width(50 * $l + $w);
} else {
$('.tool_bar').css('width', '80%');
}
}
};
Lightbox.prototype.structure = function (index) {
var $object = this, list = '', controls = '', i,
subHtmlCont1 = '', subHtmlCont2 = '', subHtmlCont3 = '',
close1 = '', close2 = '', close3 = '', socialIcons = '',
template, $arrows, $next, $prev,
$_next, $_prev, $close_bg, $download_bg, $download_bg_, $contInner, $view;
$view = (this.settings.lightboxView === 'view6') ? 'rwd-view6' : '';
this.$body.append(
this.objects.overlay = $('
')
);
this.objects.overlay.css('transition-duration', this.settings.overlayDuration + 'ms');
var $wURL = '',
$target = '';
if($object.settings.watermark && $object.settings.wURL && hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_text){
if($object.settings.wURLnewTab){
$target = 'target="_blank"';
}
$wURL = ' ';
}
for (i = 0; i < this.$items.length; i++) {
list += '' + $wURL + '
';
}
$close_bg = '' +
' ' +
' ';
switch (this.settings.lightboxView) {
case 'view1':
default:
$_next = '' +
' ' +
' ';
$_prev = '' +
' ' +
' ';
if(this.settings.showTitle){
subHtmlCont1 = '
';
}
close1 = '' + $close_bg + ' ';
break;
case 'view2':
$_next = '' +
' ' +
' ';
$_prev = '' +
' ' +
' ';
if(this.settings.showTitle){
subHtmlCont2 = '
';
}
close2 = '
' + $close_bg + ' ';
break;
case 'view3':
$_next = '' +
' ' +
' ' +
' ';
$_prev = '' +
' ' +
' ' +
' ';
if(this.settings.showTitle){
subHtmlCont1 = '
';
}
close1 = '' + $close_bg + ' ';
break;
case 'view4':
$_next = '' +
' ' +
' ';
$_prev = '' +
' ' +
' ';
$close_bg = '' +
' ' +
' ';
if(this.settings.showTitle){
subHtmlCont2 = '
';
}
close1 = '' + $close_bg + ' ';
break;
case 'view5':
case 'view6':
$_next = '' +
' ' +
' ';
$_prev = '' +
' ' +
' ';
$close_bg = '' +
' ' +
' ';
if(this.settings.showTitle){
subHtmlCont3 += '
';
}
if(this.settings.showDesc){
subHtmlCont3 += '
';
}
close1 = '' + $close_bg + ' ';
break;
case 'view7':
$_next = '' +
' ' +
' ' +
' ';
$_prev = '' +
' ' +
' ' +
' ';
$close_bg = '' +
'' +
' ' +
'' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
'' +
'' +
' ' +
'' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ';
close3 = '' +
'' + $close_bg + ' ' +
'
';
break;
}
if (this.settings.arrows && this.$items.length > 1) {
controls = '' +
'
' + $_prev + this.settings.prevHtml + '
' +
'
' + $_next + this.settings.nextHtml + '
' +
'
';
}
if (this.settings.socialSharing && (this.settings.lightboxView !== 'view5' || this.settings.lightboxView !== 'view6')) {
socialIcons = 'share
';
}
$contInner = (this.settings.lightboxView === 'view5' || this.settings.lightboxView === 'view6') ? '' + subHtmlCont3 + '
' : '';
var arrowHE = (this.settings.lightboxView !== 'view2' && this.settings.lightboxView !== 'view3') ? this.settings.arrowsHoverEffect : '',
$up = '' +
'' +
' ' +
' ',
$down = '' +
'' +
' ' +
' ',
$toggle_bar = (this.settings.lightboxView === 'view7') ? '' + $up + $down + '
' : '',
nw = '', nh = '', $lens;
if(this.settings.lightboxView === 'view7'){
nw = $object.$items.eq(index).find('img').prop('naturalWidth');
nh = $object.$items.eq(index).find('img').prop('naturalHeight');
}
$lens = (this.settings.lightboxView === 'view7') ? '' : '';
template = '' +
'
' +
'
' + list + '
' +
$contInner +
'
' +
close1 + subHtmlCont2 + $toggle_bar + $lens +
'
' +
close3 +
controls +
'
' +
close2 + subHtmlCont1 + socialIcons + '
' +
'
' +
'
';
switch($object.settings.openCloseType[0]){
case 'open_1':
case 'open_2':
case 'open_3':
case 'open_4':
case 'open_5':
case 'open_1_r':
case 'open_2_r':
case 'open_3_r':
case 'open_4_r':
case 'open_5_r':
setTimeout(function(){
$object.$cont.addClass('rwd-visible');
$('.rwd-container').addClass($object.settings.openCloseType[0]);
}, 0);
break;
default:
$('.rwd-container').addClass($object.settings.openCloseType[0]);
setTimeout(function () {
$object.$cont.addClass('rwd-visible');
}, this.settings.overlayDuration);
break;
}
if ($object.settings.socialSharing) {
setTimeout(function () {
$object.socialShare();
}, 50);
}
this.$body.append(template);
this.$cont = $('.' + $object.settings.classPrefix + 'cont');
this.$item = this.$cont.find('.' + $object.settings.classPrefix + 'item');
if (!this.settings.slideAnimation) {
this.$cont.addClass(this.settings.classPrefix + 'animation');
this.settings.slideAnimationType = this.settings.classPrefix + 'slide';
} else {
this.$cont.addClass(this.settings.classPrefix + 'use');
}
$object.calculateDimensions(index);
this.$item.eq(this.index).addClass(this.settings.classPrefix + 'current');
if (this.effectsSupport()) {
this.$cont.addClass(this.settings.classPrefix + 'support');
} else {
this.$cont.addClass(this.settings.classPrefix + 'noSupport');
this.settings.speed = 0;
}
this.$cont.addClass(this.settings.slideAnimationType);
((this.settings.showAfterLoad) && (this.$cont.addClass(this.settings.classPrefix + 'show-after-load')));
if (this.effectsSupport()) {
var $inner = this.$cont.find('.cont-inner');
$inner.css('transition-timing-function', 'ease');
$inner.css('transition-duration', this.settings.speed + 'ms');
}
switch($object.settings.lightboxView){
case 'view1':
case 'view2':
case 'view3':
$inner.css({
height: 'calc(100% - 92px)',
top: '47px'
});
break;
case 'view4':
$inner.css({
height: 'calc(100% - 92px)',
top: '45px'
});
break;
case 'view5':
jQuery('.cont-inner').css({
width: '60%'
});
break;
case 'view6':
jQuery('.cont-inner').css({
width: '80%'
});
break;
case 'view7':
$('.toggle_bar').on('click', function(){
$('.rwd-container').toggleClass('rwd_toggle_bar');
if (jQuery('.rwd-toolbar').height() === 40) {
jQuery('.rwd-toolbar').animate({
height: '',
top: jQuery('.rwd-toolbar').position().top + 40 + 'px'
}, 1000);
jQuery('.tool_bar > *').css('display', 'none');
} else {
jQuery('.rwd-toolbar').animate({
height: '40px',
top: jQuery('.rwd-toolbar').position().top - 40 + 'px'
}, 1000);
setTimeout(function () {
jQuery('.tool_bar > *').css('display', 'block');
}, 1000);
}
});
break;
}
$object.objects.overlay.addClass('in');
setTimeout(function () {
$object.$cont.addClass($object.settings.classPrefix + 'visible');
}, this.settings.overlayDuration);
if (this.settings.download) {
$download_bg = '' +
' ' +
' ';
$download_bg_ = '' +
' ' +
' ' +
' ';
switch (this.settings.lightboxView) {
case 'view1':
default:
this.$cont.find('.' + $object.settings.classPrefix + 'toolbar').append('' + $download_bg + ' ');
break;
case 'view2':
this.$cont.find('.' + $object.settings.classPrefix + 'bar').append('' + $download_bg + ' ');
break;
case 'view4':
$('' + $download_bg + ' ').insertBefore($('.rwd-title'));
break;
case 'view5':
case 'view6':
$('.rwd-toolbar').append('' + $download_bg_ + ' ');
break;
case 'view7':
$('.tool_bar').append('' + $download_bg_ + ' ');
break;
}
}
if(this.settings.lightboxView === 'view7' && hugeit_resp_lightbox_obj.hugeit_lightbox_view_info === 'true'){
var $info = '' +
' ' +
' ';
$('.tool_bar').append('' + $info + ' ');
}
$arrows = $('.rwd-arrows .rwd-next, .rwd-arrows .rwd-prev');
$next = $('.rwd-arrows .rwd-next');
$prev = $('.rwd-arrows .rwd-prev');
var title_text = $('.rwd-title');
switch (this.settings.titlePos) {
case 'left':
title_text.css({'text-align': 'left'});
break;
case 'center':
title_text.css({'text-align': 'center'});
break;
case 'right':
title_text.css({'text-align': 'right'});
break;
}
switch (this.settings.lightboxView) {
case 'view1':
default:
$arrows.css({'top': '50%'});
$next.css({'right': '20px'});
$prev.css({'left': '20px'});
break;
case 'view2':
$arrows.css({'bottom': '0'});
$next.css({'right': '40%'});
$prev.css({'left': '40%'});
break;
case 'view3':
$arrows.css({'top': '14px', 'z-index': '1090'});
$next.css({'right': '20px'});
$prev.css({'right': '55px'});
title_text.css({'text-align': 'left', 'border-top': '1px solid #999'});
$('.rwd-close').css({'margin-right': '45%'});
$('.rwd-overlay, .rwd-toolbar, .rwd-title, .rwd-next, .rwd-prev').css({'background': 'rgba(255, 255, 255, 1)'});
$('.rwd-title, .shareLook').css({'color': '#999'});
$('.rwd-toolbar').css({'border-bottom': '1px solid #999'});
$('.rwd-toolbar .rwd-icon, .rwd-arrows .rwd-icon').addClass('rwd-icon0');
break;
}
this.prevScrollTop = $(window).scrollTop();
$object.objects.content = $('.rwd-container');
$object.objects.content.css({
'width': $object.settings.width,
'height': $object.settings.height
});
if($(window).width() < 768 && this.settings.lightboxView === 'view7'){
$object.objects.content.css({
'width': '100%',
'height': '100%'
});
}
var $color, $zoomTop = (document.documentElement.clientHeight - $object.objects.content.height()) / 2;
switch (this.settings.lightboxView){
case 'view3':
$color = 'rgba(255,255,255,.9)';
break;
default:
$color = 'rgba(0,0,0,.9)';
break;
}
if(hugeit_resp_lightbox_obj.hugeit_lightbox_rightclick_protection === 'true'){
setTimeout(function () {
$('.rwd-container').bind('contextmenu', function () {
return false;
});
}, 50);
}
if(this.settings.showBorder){
$('.rwd-container').css({
border: '2px solid #999'
});
}
};
Lightbox.prototype.calculateDimensions = function (index) {
var $object = this, $width;
$width = $('.' + $object.settings.classPrefix + 'current').height() * 16 / 9;
if ($width > $object.settings.videoMaxWidth) {
$width = $object.settings.videoMaxWidth;
}
$('.' + $object.settings.classPrefix + 'video-cont ').css({
'max-width': $width + 'px'
});
if(this.settings.lightboxView === 'view7') {
var $img, $video, $_inner,
$_width, $_height, $_wrap, $wrapHeight,
$_top, $top, $left, $_left = 0, $t,
$length, $k;
setTimeout(function() {
$img = document.querySelector('.rwd-item:nth-child(' + (index + 1) + ') img');
$video = document.querySelector('.rwd-item:nth-child(' + (index + 1) + ') .rwd-video-cont');
$_inner = document.querySelector('.rwd-item:nth-child(' + (index + 1) + ') .view7_inner');
if($img && $(window).width() > 768){
$k = $object.$item.eq(index).find('img').prop('naturalWidth') / $object.$item.eq(index).find('img').prop('naturalHeight');
if ($object.$item.eq(index).find('img').prop('naturalWidth') > $object.$item.eq(index).find('img').prop('naturalHeight') && $k > 2) {
if($object.$item.eq(index).find('img').prop('naturalWidth') < 500 ){
$object.$item.eq(index).find('img').css({
minWidth: '70%'
});
}
} else {
if($object.$item.eq(index).find('img').prop('naturalHeight') < 500){
$object.$item.eq(index).find('img').css({
minHeight: '70%'
});
}
}
}
$_width = parseFloat(window.getComputedStyle($img || $video, null).width);
$_height = parseFloat(window.getComputedStyle($img || $video, null).height);
switch($img || $video){
case $img:
$_wrap = document.querySelector('.rwd-item:nth-child(' + (index + 1) + ') .rwd-img-wrap');
break;
case $video:
$_wrap = document.querySelector('.rwd-item:nth-child(' + (index + 1) + ')');
break;
}
$wrapHeight = parseFloat(window.getComputedStyle($_wrap, null).height);
$top = ($wrapHeight - $_height) / 2 + $_height - 40;
$_top = ($wrapHeight - $_height) / 2;
$left = ($('.rwd-container').width() - (parseFloat(window.getComputedStyle($_inner, null).width) + $_width)) / 2;
$t = ($object.settings.thumbnail) ? 47 : 0;
if ($('.rwd-container').width() > 768) {
$('.rwd-view7-title').eq(index).width($('.rwd-container').width() * 0.2 - 46);
$('.rwd-view7-desc').eq(index).width($('.rwd-container').width() * 0.2 - 36);
setTimeout(function(){
$('.rwd-view7-desc').height($('.view7_inner').height() - ($object.settings.showTitle ? 120 : 9));
}, 200);
$_left = ($_inner.classList.contains('is_close')) ? 0 : $('.rwd-container').width() * 0.1;
$('.rwd-toolbar').css({
width: $_width + 1 + 'px',
top: $top + $t + ($('.rwd-container').hasClass('rwd_toggle_bar') ? 40 : 0) + 1 + 'px',
left: $left + 'px'
});
$('.rwd-close-bar').css({
top: $_top + $t + 'px',
left: $left + $_width - 25 + 'px'
});
($img || $video).style.left = -$_left + ($object.settings.showBorder ? $object.settings.borderSize : 0);
$('.view7_inner').eq(index).css({
top: $_top + 'px',
left: $_left + $left + $_width + 'px',
height: $_height + 1 + 'px'
});
$('.view7_share').css({
top: $_top + $t + 12 + 'px',
right: 2*$_left + $_width + $left + 5 + 'px'
});
$length = $('.view7_share li').length + 1;
$('.view7_share, .view7_share > div').width(($_height - 42) / $length).height(($_height - 42) / $length);
$('.view7_share li').width(($_height - 42) / $length).height(($_height - 42) / $length);
} else {
$('.rwd-toolbar').css({
width: $(window).width() + 'px',
top: '0'
});
$('.rwd-toolbar .rwd-icon, .view7_share').width($(window).width() * 0.2);
$('.view7_share').css({
'top': '0',
'z-index': '999999999',
'left': ($(window).width() * 0.2 - 40) * 0.5 + 'px'
});
$('.rwd-share-buttons').css({
height: $(window).height() + 'px',
width: $(window).width() + 'px',
left: -($(window).width() * 0.2 - 40) * 0.5 + 'px'
});
$('.rwd-share-buttons li').css({
width: ($(window).width() - ($object.settings.showBorder ? 8 : 0)) * 0.2 + 'px',
maxWidth: 'none'
});
$('.rwd-share-buttons li a').css({
marginLeft: $(window).width() * 0.1 - 20 + 'px'
});
$('.rwd-close-bar').css({
top: $_top + $t + 5 + 'px',
left: ($(window).width() - $_width) / 2 + $_width - 30 + 'px'
});
}
}, 0);
}
};
Lightbox.prototype.innerOpenClose = function(){
var $object = this;
$('.info_show_hide').off('click');
$('.info_show_hide').on('click', function(){
var $view7_inner = $('.rwd-item.rwd-current').find('.view7_inner'),
$toolbar = $('.rwd-toolbar'),
$closebar = $('.rwd-close-bar'),
$imgcont = $('.rwd-item.rwd-current').find('img'),
$videoCont = $('.rwd-item.rwd-current').find('.rwd-video-cont '),
$zoomcont = $('.zoomContainer'),
$view7_share = $('.view7_share');
if($('.rwd-container').width() > 768) {
if ($('.rwd-item.rwd-current').hasClass('isImg')) {
if (!$view7_inner.hasClass('is_close')) {
$view7_inner.addClass('is_close');
$view7_inner.animate({
width: '0',
left: parseFloat($view7_inner.css('left')) + 'px'
}, 1000);
$toolbar.animate({
width: parseFloat($toolbar.css('width')) + 1 + 'px',
left: parseFloat($toolbar.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
$closebar.animate({
left: parseFloat($closebar.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
$imgcont.animate({
left: parseFloat($imgcont.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
$zoomcont.animate({
left: parseFloat($imgcont.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
$view7_share.animate({
left: parseFloat($view7_share.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
} else {
$view7_inner.removeClass('is_close');
$view7_inner.animate({
width: $('.rwd-container').width() * 0.2 + 'px',
left: parseFloat($view7_inner.css('left')) + 'px'
}, 1000);
$toolbar.animate({
width: parseFloat($toolbar.css('width')) - 1 + 'px',
left: parseFloat($toolbar.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
$closebar.animate({
left: parseFloat($closebar.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
$imgcont.animate({
left: parseFloat($imgcont.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
$zoomcont.animate({
left: parseFloat($imgcont.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
$view7_share.animate({
left: parseFloat($view7_share.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
}
} else if ($('.rwd-item.rwd-current').hasClass('isVideo')) {
if (!$view7_inner.hasClass('is_close')) {
$view7_inner.addClass('is_close');
$view7_inner.animate({
width: '0',
left: parseFloat($view7_inner.css('left')) + 'px'
}, 1000);
$toolbar.animate({
left: parseFloat($toolbar.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 0.5 + 'px'
}, 1000);
$closebar.animate({
left: parseFloat($closebar.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
$videoCont.animate({
left: parseFloat($videoCont.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
$view7_share.animate({
left: parseFloat($view7_share.css('left')) + parseFloat($view7_inner.css('width')) / 2 + 'px'
}, 1000);
} else {
$view7_inner.removeClass('is_close');
$view7_inner.animate({
width: $('.rwd-container').width() * 0.2 + 'px',
left: parseFloat($view7_inner.css('left')) + 'px'
}, 1000);
$toolbar.animate({
left: parseFloat($toolbar.css('left')) - $('.rwd-container').width() * 0.1 - 0.5 + 'px'
}, 1000);
$closebar.animate({
left: parseFloat($closebar.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
$videoCont.animate({
left: parseFloat($videoCont.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
$view7_share.animate({
left: parseFloat($view7_share.css('left')) - $('.rwd-container').width() * 0.1 + 'px'
}, 1000);
}
}
} else {
if (!$view7_inner.hasClass('is_open')) {
$view7_inner.addClass('is_open');
if($('.rwd-share-buttons').css('display') === 'block'){
$('.rwd-share-buttons').css({
'display': 'none'
});
}
$('.rwd-close-bar,.rwd-arrows .rwd-next, .rwd-arrows .rwd-prev').css({
zIndex: '1'
});
if(!$object.settings.thumbnail){
$view7_inner.css({
top: '40px'
});
}
if($object.settings.thumbnail && hugeit_resp_lightbox_obj.hugeit_lightbox_thumbs_position === '1'){
$view7_inner.css({
top: -(+hugeit_resp_lightbox_obj.hugeit_lightbox_thumbs_height) + 'px'
});
}
$view7_inner.animate({
height: $(window).height() + 'px'
}, 1000);
} else {
$view7_inner.removeClass('is_open');
$('.rwd-close-bar,.rwd-arrows .rwd-next, .rwd-arrows .rwd-prev').animate({
zIndex: '999999999'
}, 700);
$view7_inner.animate({
height: '0'
}, 1000);
}
}
});
};
Lightbox.prototype.effectsSupport = function () {
var transition, root, support;
support = function () {
transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
root = document.documentElement;
for (var i = 0; i < transition.length; i++) {
if (transition[i] in root.style) {
return transition[i] in root.style;
}
}
};
return support();
};
Lightbox.prototype.isVideo = function (src, index) {
var youtube, vimeo, dailymotion;
youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i);
dailymotion = src.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);
if (youtube) {
return {
youtube: youtube
};
} else if (vimeo) {
return {
vimeo: vimeo
};
} else if (dailymotion) {
return {
dailymotion: dailymotion
};
}
};
Lightbox.prototype.counter = function () {
if (this.settings.showCounter) {
switch (this.settings.lightboxView) {
case 'view1':
default:
$('.' + this.settings.classPrefix + 'toolbar').append(this.objects.counter = $('
'));
$('#rwd-counter').css({'padding-left': '23px'});
break;
case 'view2':
case 'view4':
case 'view7':
$('.' + this.settings.classPrefix + 'bar').append('
').append(this.objects.counter = $('
'));
break;
case 'view5':
case 'view6':
$('.contInner').append(this.objects.counter = $('
'));
break;
}
this.objects.counter.append(
this.objects.current = $('' + this.settings.sequence_info + ' ' + (parseInt(this.index, 10) + 1) + ' ' +
this.settings.sequenceInfo + ' ' + this.$items.length + '
')
);
}
};
Lightbox.prototype.setTitle = function (index) {
var $object = this, $title, $currentElement;
$currentElement = this.$items.eq(index);
$title = $currentElement.find('img').attr('alt') ||
$currentElement.find('img').attr('title') ||
this.settings.defaultTitle || '';
this.$cont.find('.' + this.settings.classPrefix + 'title').html('' + $title + '
');
(($object.settings.lightboxView === 'view2') && $('.rwd-title-text').css({'width': '100%'}));
if ($object.settings.lightboxView !== 'view1' && $object.settings.lightboxView !== 'view3' && $object.settings.lightboxView !== 'view4') {
($title === '' && $object.settings.socialSharing) ?
this.$cont.find('.' + this.settings.classPrefix + 'title').hide() :
this.$cont.find('.' + this.settings.classPrefix + 'title').show();
}
if($object.settings.lightboxView === 'view7'){
if(this.settings.showTitle){
$('.rwd-view7-title').eq(index).html($title);
}
}
};
Lightbox.prototype.setDescription = function (index) {
var $object = this, $description, $currentElement;
$currentElement = this.$items.eq(index);
$description = $currentElement.find('img').attr('data-description') || '';
this.$cont.find('.' + this.settings.classPrefix + 'description').html('' + $description + '
');
if($object.settings.lightboxView === 'view7'){
if(this.settings.showDesc){
$('.rwd-view7-desc').eq(index).html($description);
$('.rwd-view7-desc').eq(index).attr('title', $description);
}
}
};
Lightbox.prototype.preload = function (index) {
for (var i = 1; i <= this.settings.preload; i++) {
if (i >= this.$items.length - index) {
break;
}
this.loadContent(index + i, false, 0);
}
for (var j = 1; j <= this.settings.preload; j++) {
if (index - j < 0) {
break;
}
this.loadContent(index - j, false, 0);
}
};
Lightbox.prototype.socialShare = function () {
var $object = this, shareButtons;
if(this.settings.lightboxView !== 'view7'){
shareButtons = '';
} else {
var $fb = '' +
' ' +
' ';
var $gp = '' +
' ' +
' ';
var $twitter = ' ' +
' ';
var $vk = ' ';
var $pinterest = ' ';
var $linkedin = ' ';
var $tumblr = ' ';
var $reddit = ' ';
var $digg = ' ';
var $buffer = ' ';
var $yummly = ' ';
shareButtons = '';
}
switch(this.settings.lightboxView){
case 'view5':
case 'view6':
$('.contInner').append(shareButtons);
break;
case 'view7':
var $view7_share = '', $share = '', socialIcons_ = '', $m_share_event = '';
$m_share_event = "if(!this.classList.contains('share_open')){this.classList.add('share_open');document.querySelector('.rwd-share-buttons').style.visibility = 'visible';document.querySelector('.rwd-share-buttons').style.opacity = '1';document.querySelector('.rwd-share-buttons').style.display = 'block';if(document.querySelector('.rwd-current .view7_inner').classList.contains('is_open')){document.querySelector('.rwd-current .view7_inner').classList.remove('is_open');document.querySelector('.rwd-current .view7_inner').style.height = 0;document.querySelector('.rwd-close-bar').style.zIndex = 999999999;document.querySelector('.rwd-next').style.zIndex = 999999999;document.querySelector('.rwd-prev').style.zIndex = 999999999;}} else {this.classList.remove('share_open');document.querySelector('.rwd-share-buttons').style.visibility = 'hidden';document.querySelector('.rwd-share-buttons').style.opacity = '0';}";
$share ='' +
'' +
' ' +
' ';
socialIcons_ = '' + $share + '
';
var $share_event = '';
if($(window).width() > 768){
$share_event = 'onmouseover="document.querySelector(\'.share_open_close\').style.background = \'rgba(0,0,0,.85)\'; document.querySelector(\'.rwd-share-buttons\').style.visibility = \'visible\'; document.querySelector(\'.rwd-share-buttons\').style.opacity = \'1\'; document.querySelector(\'.rwd-share-buttons\').style.transition = \'visibility 0s, opacity 0.5s linear\'" '+
'onmouseout="document.querySelector(\'.share_open_close\').style.background = \'\'; document.querySelector(\'.rwd-share-buttons\').style.visibility = \'hidden\'; document.querySelector(\'.rwd-share-buttons\').style.opacity = \'0\'; document.querySelector(\'.rwd-share-buttons\').style.transition = \'visibility 0.5s, opacity 0.5s linear\'"';
}
$view7_share = '' + socialIcons_ + shareButtons + '
';
$('.rwd-container').append($view7_share);
break;
default:
$('.' + this.settings.classPrefix + 'socialIcons').append(shareButtons);
break;
}
setTimeout(function () {
$('#rwd-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=&url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-linkedin').attr('href', 'http://www.linkedin.com/shareArticle?mini=true&url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-tumblr').attr('href', 'http://www.tumblr.com/share/link?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-reddit').attr('href', 'http://reddit.com/submit?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-buffer').attr('href', 'https://bufferapp.com/add?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-digg').attr('href', 'http://www.digg.com/submit?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-vk').attr('href', 'http://vkontakte.ru/share.php?url=' + (encodeURIComponent(window.location.href)));
$('#rwd-share-yummly').attr('href', 'http://www.yummly.com/urb/verify?url=' + (encodeURIComponent(window.location.href)));
}, 200);
};
Lightbox.prototype.changeHash = function (index) {
var $object = this;
(($object.settings.socialSharing) && (window.location.hash = '/lightbox&slide=' + (index + 1)));
};
Lightbox.prototype.loadContent = function (index, rec, delay) {
var $object, src, isVideo;
$object = this;
function isImg() {
src = $object.$items.eq(index).attr('href');
return src.match(/\.(jpg|png|gif)\b/);
}
if ($object.settings.watermark) {
if (isImg()) {
src = $object.$items.eq(index).find('img').attr('data-src');
}
} else {
src = $object.$items.eq(index).attr('href');
}
var $view7_inner = '';
if(this.settings.lightboxView === 'view7'){
if(this.settings.showTitle){
var $t = '
';
}
if(this.settings.showDesc){
var $d = '
';
}
$view7_inner = '' + $t + $d + '
';
}
isVideo = $object.isVideo(src, index);
if (!$object.$item.eq(index).hasClass($object.settings.classPrefix + 'loaded')) {
if (isVideo) {
$object.$item.eq(index).addClass('isVideo');
$object.$item.eq(index).prepend('' + $view7_inner);
$object.$element.trigger('hasVideo.rwd-container', [index, src]);
} else {
$object.$item.eq(index).addClass('isImg');
$object.$item.eq(index).prepend('' +
'
' +
$view7_inner +
'
');
}
$object.$element.trigger('onAferAppendSlide.rwd-container', [index]);
$object.$item.eq(index).addClass($object.settings.classPrefix + 'loaded');
}
$object.$item.eq(index).find('.' + $object.settings.classPrefix + 'object').on('load.rwd-container error.rwd-container', function () {
var speed = 0;
if (delay) {
speed = delay;
}
setTimeout(function () {
$object.$item.eq(index).addClass($object.settings.classPrefix + 'complete');
}, speed);
});
if (rec === true) {
if (!$object.$item.eq(index).hasClass($object.settings.classPrefix + 'complete')) {
$object.$item.eq(index).find('.' + $object.settings.classPrefix + 'object').on('load.rwd-container error.rwd-container', function () {
$object.preload(index);
});
} else {
$object.preload(index);
}
}
if(this.settings.lightboxView !== 'view7' && hugeit_resp_lightbox_obj.hugeit_lightbox_imageframe !== 'frame_0'){
$('.rwd-image').css({
borderColor: '#f4be52',
borderStyle: 'inset',
borderWidth: '60px'
});
if(hugeit_resp_lightbox_obj.hugeit_lightbox_imageframe !== 'frame_8'){
$('.rwd-image').css({
borderImage: 'url("' + hugeit_resp_lightbox_plugins_url + hugeit_resp_lightbox_obj.hugeit_lightbox_imageframe + '.png") 90 95 95 90 stretch stretch'
});
} else {
$('.rwd-image').css({
borderImage: 'url("' + hugeit_resp_lightbox_plugins_url + hugeit_resp_lightbox_obj.hugeit_lightbox_imageframe + '.png") 90 123 85 129 stretch stretch'
});
}
}
};
Lightbox.prototype.slide = function (index, fromSlide, fromThumb) {
var $object, prevIndex;
$object = this;
prevIndex = this.$cont.find('.' + $object.settings.classPrefix + 'current').index();
if(this.settings.lightboxView === 'view7'){
this.innerOpenClose();
setTimeout(function(){
var nw, nh;
if($('.rwd-current').hasClass('isImg')){
nw = document.querySelector('.rwd-current img').naturalWidth;
nh = document.querySelector('.rwd-current img').naturalHeight;
} else if($('.rwd-current').hasClass('isVideo')){
nw = $('.rwd-current iframe').width();
nh = $('.rwd-current iframe').height();
}
$('.img_size').html(nw + 'px × ' + nh + 'px');
}, 200);
}
var length = this.$item.length,
time = 0,
next = false,
prev = false;
if (this.settings.download) {
var src;
if (!this.settings.watermark) {
src = $object.$items.eq(index).attr('data-download-url') !== 'false' && ($object.$items.eq(index).attr('data-download-url') || $object.$items.eq(index).attr('href'));
}
else {
src = $object.$items.eq(index).find('img').attr('data-src');
}
if (src) {
$('#' + $object.settings.classPrefix + 'download').attr('href', src);
$object.$cont.removeClass($object.settings.classPrefix + 'hide-download');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-actual-size');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-fullwidth');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-zoom-in');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-zoom-out');
} else {
$object.$cont.addClass($object.settings.classPrefix + 'hide-download');
$object.$cont.addClass($object.settings.classPrefix + 'hide-actual-size');
$object.$cont.addClass($object.settings.classPrefix + 'hide-fullwidth');
$object.$cont.addClass($object.settings.classPrefix + 'hide-zoom-in');
$object.$cont.addClass($object.settings.classPrefix + 'hide-zoom-out');
}
} else {
if(this.$cont.find('.' + $object.settings.classPrefix + 'item').eq(index).find('iframe').length){
$object.$cont.addClass($object.settings.classPrefix + 'hide-download');
$object.$cont.addClass($object.settings.classPrefix + 'hide-actual-size');
$object.$cont.addClass($object.settings.classPrefix + 'hide-fullwidth');
$object.$cont.addClass($object.settings.classPrefix + 'hide-zoom-in');
$object.$cont.addClass($object.settings.classPrefix + 'hide-zoom-out');
} else {
$object.$cont.removeClass($object.settings.classPrefix + 'hide-download');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-actual-size');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-fullwidth');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-zoom-in');
$object.$cont.removeClass($object.settings.classPrefix + 'hide-zoom-out');
}
}
this.$element.trigger('onBeforeSlide.rwd-container', [prevIndex, index, fromSlide, fromThumb]);
setTimeout(function () {
$object.setTitle(index);
}, time);
if ($object.settings.lightboxView === 'view5' || $object.settings.lightboxView === 'view6' || $object.settings.lightboxView === 'view7') {
setTimeout(function () {
$object.setDescription(index);
}, time);
}
this.arrowDisable(index);
$object.$cont.addClass($object.settings.classPrefix + 'no-trans');
this.$item.removeClass($object.settings.classPrefix + 'prev-slide ' + $object.settings.classPrefix + 'next-slide');
if (!fromSlide) {
if (index < prevIndex) {
prev = true;
if ((index === 0) && (prevIndex === length - 1) && !fromThumb) {
prev = false;
next = true;
}
} else if (index > prevIndex) {
next = true;
if ((index === length - 1) && (prevIndex === 0) && !fromThumb) {
prev = true;
next = false;
}
}
if (prev) {
this.$item.eq(index).addClass($object.settings.classPrefix + 'prev-slide');
this.$item.eq(prevIndex).addClass($object.settings.classPrefix + 'next-slide');
} else if (next) {
this.$item.eq(index).addClass($object.settings.classPrefix + 'next-slide');
this.$item.eq(prevIndex).addClass($object.settings.classPrefix + 'prev-slide');
}
setTimeout(function () {
$object.$item.removeClass($object.settings.classPrefix + 'current');
$object.$item.eq(index).addClass($object.settings.classPrefix + 'current');
$object.$cont.removeClass($object.settings.classPrefix + 'no-trans');
}, 50);
} else {
var slidePrev = index - 1;
var slideNext = index + 1;
if ((index === 0) && (prevIndex === length - 1)) {
slideNext = 0;
slidePrev = length - 1;
} else if ((index === length - 1) && (prevIndex === 0)) {
slideNext = 0;
slidePrev = length - 1;
}
this.$item.removeClass($object.settings.classPrefix + 'prev-slide ' + $object.settings.classPrefix + 'current ' + $object.settings.classPrefix + 'next-slide');
$object.$item.eq(slidePrev).addClass($object.settings.classPrefix + 'prev-slide');
$object.$item.eq(slideNext).addClass($object.settings.classPrefix + 'next-slide');
$object.$item.eq(index).addClass($object.settings.classPrefix + 'current');
}
$object.loadContent(index, true, $object.settings.overlayDuration);
$object.$element.trigger('onAfterSlide.rwd-container', [prevIndex, index, fromSlide, fromThumb]);
if (this.settings.showCounter) {
$('#' + $object.settings.classPrefix + 'counter-current').text(index + 1);
}
if (this.settings.socialSharing) {
$object.changeHash(index);
}
var $top, $left, $wWidth, $wHeight, $imgWidth, $imgHeight, $wmWidth, $wmHeight, $pos, $item;
$item = $('.rwd-item.rwd-current');
$pos = +hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_margin;
$wWidth = +hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_containerWidth;
$wHeight = +hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_textFontSize;
$imgWidth = $object.$item.eq(index).find('img').width();
$imgHeight = $object.$item.eq(index).find('img').height();
$wmWidth = $item.width();
$wmHeight = $item.height();
switch ('pos' + hugeit_resp_lightbox_obj.hugeit_lightbox_watermark_position_new) {
case 'pos1':
$top = ($wmHeight - $imgHeight) / 2 + $pos;
$left = ($wmWidth - $imgWidth) / 2 + $pos;
break;
case 'pos2':
$top = ($wmHeight - $imgHeight) / 2 + $pos;
$left = ($wmWidth - $wWidth) / 2;
break;
case 'pos3':
$top = ($wmHeight - $imgHeight) / 2 + $pos;
$left = ($wmWidth + $imgWidth) / 2 - $wWidth - $pos;
break;
case 'pos4':
$top = ($wmHeight - $wHeight) / 2;
$left = ($wmWidth - $imgWidth) / 2 + $pos;
break;
case 'pos5':
$top = ($wmHeight - $wHeight) / 2;
$left = ($wmWidth - $wWidth) / 2;
break;
case 'pos6':
$top = ($wmHeight - $wHeight) / 2;
$left = ($wmWidth + $imgWidth) / 2 - $wWidth - $pos;
break;
case 'pos7':
$top = ($wmHeight + $imgHeight) / 2 - $wHeight - $pos;
$left = ($wmWidth - $imgWidth) / 2 + $pos;
break;
case 'pos8':
$top = ($wmHeight + $imgHeight) / 2 - $wHeight - $pos;
$left = ($wmWidth - $wWidth) / 2;
break;
case 'pos9':
$top = ($wmHeight + $imgHeight) / 2 - $wHeight - $pos;
$left = ($wmWidth + $imgWidth) / 2 - $wWidth - $pos;
break;
default:
$top = ($wmHeight - $wHeight) / 2;
$left = ($wmWidth - $wWidth) / 2;
}
$('.w_url').css({
position: 'absolute',
width: $wWidth + 'px',
height: $wHeight + 'px',
top: $top + 'px',
left: $left + 'px'
});
$object.calculateDimensions(index);
$('.rwd-container .rwd-thumb-item img').css({
opacity: 1 - 10 / 100
});
$('.rwd-container .rwd-thumb-item.active img').css({
opacity: 1
});
if(this.settings.lightboxView === 'view7'){
this.$element.on('onBeforeSlide.rwd-container', function() {
$('.view7_share, .rwd-close-bar, .rwd-toolbar').css({
visibility: 'hidden',
opacity: '0',
transition: 'visibility 0s, opacity 0.5s linear'
});
});
this.$element.on('onAfterSlide.rwd-container', function() {
setTimeout(function(){
$('.view7_share, .rwd-close-bar, .rwd-toolbar').css({
visibility: 'visible',
opacity: '1'
});
}, 450);
});
}
$(window).on('resize.rwd-container orientationchange.rwd-container', function () {
var $t = ($object.settings.lightboxView !== 'view7') ? 100 : 0;
setTimeout(function () {
$object.calculateDimensions(index);
}, $t);
});
};
Lightbox.prototype.goToNextSlide = function (fromSlide) {
var $object = this,
$cont = $('.rwd-cont'),
$imageObject, k;
if (($object.index + 1) < $object.$item.length) {
$object.index++;
$object.slide($object.index, fromSlide, false);
} else {
if ($object.settings.loop === 'true') {
$object.index = 0;
$object.slide($object.index, fromSlide, false);
}
}
if ($object.settings.fullwidth && $cont.hasClass('rwd-fullwidth-on')) {
$imageObject = $cont.find('.rwd-image').eq($object.index);
k = $imageObject.width() / $imageObject.height();
if ($imageObject.width() > $imageObject.height() && k > 2) {
$imageObject.css({
'min-width': '100%'
});
} else {
$imageObject.css({
'min-height': '100%'
});
}
}
};
Lightbox.prototype.goToPrevSlide = function (fromSlide) {
var $object = this,
$cont = $('.rwd-cont'),
$imageObject, k;
if ($object.index > 0) {
$object.index--;
$object.slide($object.index, fromSlide, false);
} else {
if ($object.settings.loop === 'true') {
$object.index = $object.$items.length - 1;
$object.slide($object.index, fromSlide, false);
}
}
if ($object.settings.fullwidth && $cont.hasClass('rwd-fullwidth-on')) {
$imageObject = $cont.find('.rwd-image').eq($object.index);
k = $imageObject.width() / $imageObject.height();
if ($imageObject.width() > $imageObject.height() && k > 2) {
$imageObject.css({
'min-width': '100%'
});
} else {
$imageObject.css({
'min-height': '100%'
});
}
}
};
Lightbox.prototype.slideShow = function () {
var $object = this, $toolbar, $play_bg, $pause_bg;
$play_bg = '' +
' ' +
' ';
$pause_bg = '' +
' ' +
' ';
$toolbar = $('.' + $object.settings.classPrefix + 'toolbar');
switch (this.settings.lightboxView) {
case 'view1':
default:
$toolbar.append('' + $play_bg + $pause_bg + ' ');
break;
case 'view2':
$('.' + $object.settings.classPrefix + 'bar').append('' + $play_bg + $pause_bg + ' ');
break;
case 'view3':
$toolbar.append('' + $play_bg + $pause_bg + ' ');
$('.rwd-toolbar .rwd-icon').addClass('rwd-icon0');
break;
case 'view4':
$('' + $play_bg + $pause_bg + ' ').insertBefore($('.rwd-title'));
$('.rwd-toolbar .rwd-icon').addClass('rwd-icon0');
break;
case 'view7':
$('.tool_bar').append('' + $play_bg + $pause_bg + ' ');
break;
}
if ($object.settings.slideshowAuto) {
$object.slideshowAuto();
}
$object.$cont.find('.' + $object.settings.classPrefix + 'autoplay-button').on('click.rwd-container', function () {
!$($object.$cont).hasClass($object.settings.classPrefix + 'show-autoplay') ? $object.startSlide() : $object.stopSlide();
});
};
Lightbox.prototype.slideshowAuto = function () {
var $object = this;
$object.$cont.addClass('' + $object.settings.classPrefix + 'show-autoplay');
$object.startSlide();
};
Lightbox.prototype.startSlide = function () {
var $object = this;
$object.$cont.addClass('' + $object.settings.classPrefix + 'show-autoplay');
$('.rwd-autoplay-button > .pause_bg').css({'display': 'inline-block'});
$('.rwd-autoplay-button > .play_bg').css({'display': 'none'});
$object.interval = setInterval(function () {
$object.goToNextSlide();
}, $object.settings.slideshowSpeed);
};
Lightbox.prototype.stopSlide = function () {
clearInterval(this.interval);
this.$cont.removeClass(this.settings.classPrefix + 'show-autoplay');
$('.rwd-thumb').removeClass('thumb_move');
$('.rwd-autoplay-button > .pause_bg').css({'display': 'none'});
$('.rwd-autoplay-button > .play_bg').css({'display': 'inline-block'});
};
Lightbox.prototype.addKeyEvents = function () {
var $object = this;
if (this.$items.length > 1) {
$(window).on('keyup.rwd-container', function (e) {
if ($object.$items.length > 1) {
if (e.keyCode === 37) {
e.preventDefault();
$object.goToPrevSlide();
}
if (e.keyCode === 39) {
e.preventDefault();
$object.goToNextSlide();
}
}
});
}
$(window).on('keydown.rwd-container', function (e) {
if ($object.settings.escKey === true && e.keyCode === 27) {
e.preventDefault();
if (!$object.$cont.hasClass($object.settings.classPrefix + 'thumb-open')) {
$object.destroy();
} else {
$object.$cont.removeClass($object.settings.classPrefix + 'thumb-open');
}
}
});
};
Lightbox.prototype.arrow = function () {
var $object = this;
this.$cont.find('.' + $object.settings.classPrefix + 'prev').on('click.rwd-container', function () {
$object.goToPrevSlide();
});
this.$cont.find('.' + $object.settings.classPrefix + 'next').on('click.rwd-container', function () {
$object.goToNextSlide();
});
};
Lightbox.prototype.arrowDisable = function (index) {
if (!this.settings.loop === 'true' && this.settings.hideControlOnEnd) {
if ((index + 1) < this.$item.length) {
this.$cont.find('.' + this.settings.classPrefix + 'next').removeAttr('disabled').removeClass('disabled');
} else {
this.$cont.find('.' + this.settings.classPrefix + 'next').attr('disabled', 'disabled').addClass('disabled');
}
if (index > 0) {
this.$cont.find('.' + this.settings.classPrefix + 'prev').removeAttr('disabled').removeClass('disabled');
} else {
this.$cont.find('.' + this.settings.classPrefix + 'prev').attr('disabled', 'disabled').addClass('disabled');
}
}
};
Lightbox.prototype.mousewheel = function () {
var $object = this, delta;
$object.$cont.on('mousewheel', function (e) {
e = e || window.event;
delta = e.deltaY || e.detail || e.wheelDelta;
(delta > 0) ? $object.goToNextSlide() : $object.goToPrevSlide();
e.preventDefault ? e.preventDefault() : (e.returnValue = false);
});
};
Lightbox.prototype.closeGallery = function () {
var $object = this, mousedown = false;
this.$cont.find('.' + $object.settings.classPrefix + 'close').on('click.rwd-container', function () {
$object.destroy();
});
if ($object.settings.overlayClose === 'true') {
$object.$cont.on('mousedown.rwd-container', function (e) {
mousedown = ($(e.target).is('.' + $object.settings.classPrefix + 'cont') || $(e.target).is('.' + $object.settings.classPrefix + 'item ') || $(e.target).is('.' + $object.settings.classPrefix + 'img-wrap'));
});
$object.$cont.on('mouseup.rwd-container', function (e) {
if ($(e.target).is('.contInner') || $(e.target).is('.' + $object.settings.classPrefix + 'cont') || $(e.target).is('.' + $object.settings.classPrefix + 'item ') || $(e.target).is('.' + $object.settings.classPrefix + 'img-wrap') && mousedown) {
if (!$object.$cont.hasClass($object.settings.classPrefix + 'dragEvent')) {
$object.destroy();
}
}
});
}
};
Lightbox.prototype.destroy = function (d) {
var $object = this, $time;
$('.rwd-container').removeClass(this.settings.openCloseType[0]).addClass(this.settings.openCloseType[1]);
switch(this.settings.openCloseType[1]){
case 'close_1':
case 'close_1_r':
$time = 1000;
break;
case 'close_2':
case 'close_2_r':
$time = 300;
break;
case 'close_3':
case 'close_4':
case 'close_3_r':
case 'close_4_r':
$time = 340;
break;
case 'close_5':
case 'close_5_r':
$time = 250;
break;
}
$('html, body').on('mousewheel', function(){
return false;
});
setTimeout(function(){
clearInterval($object.interval);
$object.$body.removeClass($object.settings.classPrefix + 'on');
$(window).scrollTop($object.prevScrollTop);
if (d) {
$.removeData($object.el, 'lightbox');
}
($object.settings.socialSharing && (window.location.hash = ''));
$object.$element.off('.rwd-container');
$(window).off('.rwd-container');
if ($object.$cont) {
$object.$cont.removeClass($object.settings.classPrefix + 'visible');
}
$object.objects.overlay.removeClass('in');
setTimeout(function () {
if ($object.$cont) {
$object.$cont.remove();
}
$object.objects.overlay.remove();
}, $object.settings.overlayDuration + 50);
window.scrollTo(0, $object.$_y_);
$.fn.lightbox.lightboxModul['modul'].prototype.destroy();
$('html, body').off('mousewheel');
}, $time);
};
$.fn.lightbox = function (options) {
return this.each(function () {
if (!$.data(this, 'lightbox')) {
$.data(this, 'lightbox', new Lightbox(this, options));
}
});
};
$.fn.lightbox.lightboxModul = {};
var Modul = function (element) {
this.dataL = $(element).data('lightbox');
this.$element = $(element);
this.dataL.modulSettings = $.extend({}, this.constructor.defaultsModul);
this.init();
if (this.dataL.modulSettings.zoom && this.dataL.effectsSupport()) {
if(hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView !== 'view7' && this.dataL.modulSettings.zoomType === '0'){
this.initZoom();
this.zoomabletimeout = false;
this.pageX = $(window).width() / 2;
this.pageY = ($(window).height() / 2) + $(window).scrollTop();
}
}
if (hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView !== 'view7' && this.dataL.modulSettings.fullwidth && this.dataL.effectsSupport()) {
this.initFullWidth();
}
this.$el = $(element);
this.$thumbCont = null;
this.thumbContWidth = 0;
this.thumbTotalWidth = (this.dataL.$items.length * (this.dataL.modulSettings.thumbsWidth + this.dataL.modulSettings.thumbMargin));
this.thumbIndex = this.dataL.index;
this.left = 0;
if(hugeit_resp_lightbox_obj.hugeit_lightbox_thumbs === 'true'){
this.initThumbs();
}
if(this.dataL.modulSettings.fullscreen){
this.initFullscreen();
}
return this;
};
Modul.defaultsModul = {
idPrefix: 'rwd-',
classPrefix: 'rwd-',
attrPrefix: 'data-',
videoMaxWidth: '700',
fullwidth: hugeit_resp_lightbox_obj.hugeit_lightbox_fullwidth_effect === 'true',
zoom: hugeit_resp_lightbox_obj.hugeit_lightbox_zoom,
scale: +hugeit_resp_lightbox_obj.hugeit_lightbox_zoomsize / 10,
thumbnail: hugeit_resp_lightbox_obj.hugeit_lightbox_thumbs,
thumbsWidth: 100,
thumbsHeight: 100,
thumbMargin: 5,
showByDefault: true,
toogleThumb: false,
thumbPosition: '0',
thumbsOverlayColor: 'black',
thumbsOverlayOpacity: 10,
fullscreen: hugeit_resp_lightbox_obj.hugeit_lightbox_fullscreen_effect === 'true'
};
Modul.prototype.init = function () {
var $object = this;
$object.dataL.$element.on('hasVideo.rwd-container', function (event, index, src) {
$object.dataL.$item.eq(index).find('.' + $object.dataL.modulSettings.classPrefix + 'video').append($object.loadVideo(src, '' + $object.dataL.modulSettings.classPrefix + 'object', index));
});
$object.dataL.$element.on('onAferAppendSlide.rwd-container', function (event, index) {
$object.dataL.$item.eq(index).find('.' + $object.dataL.settings.classPrefix + 'video-cont').css({
'max-width': $object.dataL.modulSettings.videoMaxWidth + 'px'
});
});
$object.dataL.$element.on('onBeforeSlide.rwd-container', function (event, prevIndex, index) {
var $videoSlide = $object.dataL.$item.eq(prevIndex),
youtubePlayer = $videoSlide.find('.rwd-youtube').get(0),
vimeoPlayer = $videoSlide.find('.rwd-vimeo').get(0),
dailymotionPlayer = $videoSlide.find('.rwd-dailymotion').get(0);
if (youtubePlayer) {
youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
} else if (vimeoPlayer) {
try {
$f(vimeoPlayer).api('pause');
} catch (e) {
console.error('Make sure you have included froogaloop2 js');
}
} else if (dailymotionPlayer) {
dailymotionPlayer.contentWindow.postMessage('pause', '*');
}
var src;
src = $object.dataL.$items.eq(index).attr('href');
var isVideo = $object.dataL.isVideo(src, index) || {};
if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) {
$object.dataL.$cont.addClass($object.dataL.modulSettings.classPrefix + 'hide-download');
$object.dataL.$cont.addClass($object.dataL.modulSettings.classPrefix + 'hide-actual-size');
$object.dataL.$cont.addClass($object.dataL.modulSettings.classPrefix + 'hide-fullwidth');
$object.dataL.$cont.addClass($object.dataL.modulSettings.classPrefix + 'hide-zoom-in');
$object.dataL.$cont.addClass($object.dataL.modulSettings.classPrefix + 'hide-zoom-out');
}
});
$object.dataL.$element.on('onAfterSlide.rwd-container', function (event, prevIndex) {
$object.dataL.$item.eq(prevIndex).removeClass($object.dataL.modulSettings.classPrefix + 'video-playing');
});
};
Modul.prototype.loadVideo = function (src, addClass, index) {
var video = '',
autoplay = 0,
a = '',
isVideo = this.dataL.isVideo(src, index) || {};
if (isVideo.youtube) {
a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1';
video = '';
} else if (isVideo.vimeo) {
a = '?autoplay=' + autoplay + '&api=1';
video = '';
} else if (isVideo.dailymotion) {
a = '?wmode=opaque&autoplay=' + autoplay + '&api=postMessage';
video = '';
}
return video;
};
Modul.prototype.initFullscreen = function() {
var fullScreen = '';
if (this.dataL.modulSettings.fullscreen) {
if (!document.fullscreenEnabled && !document.webkitFullscreenEnabled && !document.mozFullScreenEnabled && !document.msFullscreenEnabled) {
return;
} else {
fullScreen = '' +
'' +
' ' +
' ' +
'' +
' ' +
' ' +
' ';
switch (hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView) {
case 'view1':
default:
$('.rwd-cont').find('.rwd-toolbar').append(fullScreen);
break;
case 'view2':
$('.rwd-cont').find('.rwd-bar').append(fullScreen);
break;
case 'view4':
$(fullScreen).insertBefore('.rwd-title');
break;
case 'view7':
$('.tool_bar').append(fullScreen);
break;
}
this.fullScreen();
}
}
};
Modul.prototype.requestFullscreen = function() {
var el = document.documentElement;
if (el.requestFullscreen) {
el.requestFullscreen();
} else if (el.msRequestFullscreen) {
el.msRequestFullscreen();
} else if (el.mozRequestFullScreen) {
el.mozRequestFullScreen();
} else if (el.webkitRequestFullscreen) {
el.webkitRequestFullscreen();
}
};
Modul.prototype.exitFullscreen = function() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
};
Modul.prototype.fullScreen = function() {
var $object = this;
$(document).on('fullscreenchange.rwd-container webkitfullscreenchange.rwd-container mozfullscreenchange.rwd-container MSFullscreenChange.rwd-container', function() {
$('.rwd-cont').toggleClass('rwd-fullscreen-on');
});
$('.rwd-cont').find('.rwd-fullscreen').on('click.rwd-container', function() {
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
$object.requestFullscreen();
} else {
$object.exitFullscreen();
}
});
$(window).on('keydown', function(e){
if(e.keyCode === 27){
console.log(1);
}
});
};
Modul.prototype.initFullWidth = function () {
var $object = this,
$fullWidth, $fullWidthOn;
$fullWidth = '' +
' ';
$fullWidthOn = '' +
' ';
if (this.dataL.modulSettings.fullwidth) {
var fullwidth = '' + $fullWidth + $fullWidthOn + ' ';
switch (hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView) {
case 'view1':
default:
this.dataL.$cont.find('.rwd-toolbar').append(fullwidth);
break;
case 'view2':
this.dataL.$cont.find('.rwd-bar').append(fullwidth);
break;
case 'view4':
$(fullwidth).insertBefore('.rwd-title');
break;
}
}
if (this.dataL.modulSettings.fullwidth) {
$('.rwd-fullwidth').on('click.rwd-container', function () {
!$('.rwd-cont').hasClass('rwd-fullwidth-on') ? $object.onFullWidth() : $object.offFullWidth();
});
}
};
Modul.prototype.onFullWidth = function () {
var $imageObject = this.dataL.$cont.find('.rwd-current .rwd-image');
$('#rwd-fullwidth').css({'display': 'none'});
$('#rwd-fullwidth_on').css({'display': 'inline-block'});
$('.rwd-cont').addClass('rwd-fullwidth-on');
$('.rwd-container').css({
width: '100%',
height: '100%'
});
var k = $imageObject.width() / $imageObject.height();
if ($imageObject.width() > $imageObject.height() && k > 2) {
$imageObject.css({
'min-width': '100%'
});
} else {
$imageObject.css({
'min-height': '100%'
});
}
};
Modul.prototype.offFullWidth = function () {
var $imageObject = this.dataL.$cont.find('.rwd-current .rwd-image');
$('#rwd-fullwidth').css({'display': 'inline-block'});
$('#rwd-fullwidth_on').css({'display': 'none'});
$('.rwd-cont').removeClass('rwd-fullwidth-on');
$('.rwd-container').css({
width: hugeit_resp_lightbox_obj.hugeit_lightbox_width_new + '%',
height: hugeit_resp_lightbox_obj.hugeit_lightbox_height_new + '%'
});
$imageObject.css({
'min-width': '',
'min-height': ''
});
};
Modul.prototype.initZoom = function () {
var $object = this, zoomIcons,
$zoomIn, $zoomOut, scale;
$zoomIn = '' +
' ' +
' ' +
' ';
$zoomOut = '' +
' ' +
' ' +
' ';
zoomIcons = '' + $zoomOut + ' ' + $zoomIn + ' ';
switch (hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView) {
case 'view1':
default:
this.dataL.$cont.find('.rwd-toolbar').append(zoomIcons);
break;
case 'view2':
this.dataL.$cont.find('.rwd-bar').append(zoomIcons);
break;
case 'view4':
$(zoomIcons).insertBefore('.rwd-title');
break;
}
scale = 1;
function zoom(scaleVal) {
var $imageObject, _x, _y, offsetX, offsetY, x, y;
$imageObject = $object.dataL.$cont.find('.rwd-current .rwd-image');
offsetX = ($(window).width() - $imageObject.width()) / 2;
offsetY = (($(window).height() - $imageObject.height()) / 2) + $(window).scrollTop();
_x = $object.pageX - offsetX;
_y = $object.pageY - offsetY;
x = _x;
y = _y;
$imageObject.css('transform', 'scale3d(' + scaleVal + ', ' + scaleVal + ', 1)').attr('data-scale', scaleVal);
$imageObject.parent().css({
transform: 'translate3d(0, ' + -y + 'px, 0)'
}).attr('data-y', -y);
}
function callScale() {
if (scale > 1) {
$object.dataL.$cont.addClass('rwd-zoomed');
} else {
$object.dataL.$cont.removeClass('rwd-zoomed');
}
if (scale < 1) {
scale = 1;
}
zoom(scale);
}
$(window).on('resize.rwd-container.zoom scroll.rwd-container.zoom orientationchange.rwd-container.zoom', function () {
$object.pageX = $(window).width() / 2;
$object.pageY = ($(window).height() / 2) + $(window).scrollTop();
zoom(scale);
});
$('#rwd-zoom-out').on('click.rwd-container', function () {
if ($object.dataL.$cont.find('.rwd-current .rwd-image').length) {
scale -= $object.dataL.modulSettings.scale;
callScale();
}
});
$('#rwd-zoom-in').on('click.rwd-container', function () {
if ($object.dataL.$cont.find('.rwd-current .rwd-image').length) {
scale += $object.dataL.modulSettings.scale;
callScale();
}
});
if (hugeit_resp_lightbox_obj.hugeit_lightbox_zoomlogo !== '0') {
$object.dataL.$cont.dblclick(function () {
if (!$object.dataL.$cont.hasClass('dbl-zoomed')) {
$object.dataL.$cont.addClass('dbl-zoomed');
if ($object.dataL.$cont.find('.rwd-current .rwd-image').length) {
scale += $object.dataL.modulSettings.scale;
callScale();
}
} else {
$object.dataL.$cont.removeClass('dbl-zoomed');
if ($object.dataL.$cont.find('.rwd-current .rwd-image').length) {
scale -= $object.dataL.modulSettings.scale;
callScale();
}
}
});
}
if (!('ontouchstart' in document.documentElement)) {
$object.zoomDrag();
}
if (('ontouchstart' in document.documentElement)) {
$object.zoomSwipe();
}
};
Modul.prototype.touchendZoom = function (startCoords, endCoords, abscissa, ordinate) {
var $object = this, _$el, $imageObject, distanceX, distanceY, maxX, maxY;
_$el = $object.dataL.$item.eq($object.dataL.index).find('.rwd-img-wrap');
$imageObject = $object.dataL.$item.eq($object.dataL.index).find('.rwd-object');
maxX = Math.abs($imageObject.outerWidth() * Math.abs($imageObject.attr('data-scale')) - $object.dataL.$cont.find('.rwd-container').width()) / 2;
maxY = Math.abs($imageObject.outerHeight() * Math.abs($imageObject.attr('data-scale')) - $object.dataL.$cont.find('.rwd-container').height()) / 2 + $(window).scrollTop();
if (_$el.attr('data-x')) {
distanceX = +_$el.attr('data-x') + (endCoords.x - startCoords.x);
} else {
distanceX = endCoords.x - startCoords.x;
}
distanceY = +_$el.attr('data-y') + (endCoords.y - startCoords.y);
if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) {
if (abscissa) {
if (endCoords.x - startCoords.x < 0) {
if(distanceX <= -maxX){
distanceX = -maxX;
}
} else {
if(distanceX >= maxX) {
distanceX = maxX;
}
}
_$el.attr('data-x', distanceX);
}
if (ordinate) {
if (endCoords.y - startCoords.y < 0) {
if(distanceY <= -(maxY + ($object.pageY - ($(window).height() - $imageObject.height()) / 2)) + 2 * $(window).scrollTop()) {
distanceY = -(maxY + ($object.pageY - ($(window).height() - $imageObject.height()) / 2)) + 2 * $(window).scrollTop();
}
} else {
if(distanceY >= maxY - ($object.pageY - ($(window).height() - $imageObject.height()) / 2)) {
distanceY = maxY - ($object.pageY - ($(window).height() - $imageObject.height()) / 2);
}
}
_$el.attr('data-y', distanceY);
}
_$el.css({
transform: 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'
});
}
};
Modul.prototype.zoomDrag = function () {
var $object = this,
startCoords = {},
endCoords = {},
isDraging = false,
isMoved = false,
abscissa = false,
ordinate = false;
$object.dataL.$item.on('mousedown.rwd-container.zoom', function (e) {
var $imageObject = $object.dataL.$item.eq($object.dataL.index).find('.rwd-object');
ordinate = $imageObject.outerHeight() * $imageObject.attr('data-scale') > $object.dataL.$cont.find('.rwd-container').height();
abscissa = $imageObject.outerWidth() * $imageObject.attr('data-scale') > $object.dataL.$cont.find('.rwd-container').width();
if ($object.dataL.$cont.hasClass('rwd-zoomed')) {
if ($(e.target).hasClass('rwd-object') && (abscissa || ordinate)) {
e.preventDefault();
startCoords = {
x: e.pageX,
y: e.pageY
};
isDraging = true;
$object.dataL.$cont.scrollLeft += 1;
$object.dataL.$cont.scrollLeft -= 1;
}
}
});
$(window).on('mousemove.rwd-container.zoom', function (e) {
if (isDraging) {
var _$el = $object.dataL.$item.eq($object.dataL.index).find('.rwd-img-wrap');
var distanceX;
var distanceY;
isMoved = true;
endCoords = {
x: e.pageX,
y: e.pageY
};
if (_$el.attr('data-x')) {
distanceX = +_$el.attr('data-x') + (endCoords.x - startCoords.x);
} else {
distanceX = endCoords.x - startCoords.x;
}
if (ordinate) {
distanceY = +_$el.attr('data-y') + (endCoords.y - startCoords.y);
}
_$el.css({
transform: 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'
});
}
});
$(window).on('mouseup.rwd-container.zoom', function (e) {
if (isDraging) {
isDraging = false;
if (isMoved && ((startCoords.x !== endCoords.x) || (startCoords.y !== endCoords.y))) {
endCoords = {
x: e.pageX,
y: e.pageY
};
$object.touchendZoom(startCoords, endCoords, abscissa, ordinate);
}
isMoved = false;
}
});
};
Modul.prototype.zoomSwipe = function () {
var $object = this,
startCoords = {},
endCoords = {},
isMoved = false,
abscissa = false, ordinate = false;
$object.dataL.$item.on('touchstart.rwd-container', function (e) {
if ($object.dataL.$cont.hasClass('rwd-zoomed')) {
var $imageObject = $object.dataL.$item.eq($object.dataL.index).find('.rwd-object');
ordinate = $imageObject.outerHeight() * $imageObject.attr('data-scale') > $object.dataL.$cont.find('.rwd-container').height();
abscissa = $imageObject.outerWidth() * $imageObject.attr('data-scale') > $object.dataL.$cont.find('.rwd-container').width();
if ((abscissa || ordinate)) {
e.preventDefault();
startCoords = {
x: e.originalEvent.targetTouches[0].pageX,
y: e.originalEvent.targetTouches[0].pageY
};
}
}
});
$object.dataL.$item.on('touchmove.rwd-container', function (e) {
if ($object.dataL.$cont.hasClass('rwd-zoomed')) {
var _$el = $object.dataL.$item.eq($object.dataL.index).find('.rwd-img-wrap');
var distanceX;
var distanceY;
e.preventDefault();
isMoved = true;
endCoords = {
x: e.originalEvent.targetTouches[0].pageX,
y: e.originalEvent.targetTouches[0].pageY
};
if (_$el.attr('data-x')) {
distanceX = +_$el.attr('data-x') + (endCoords.x - startCoords.x);
} else {
distanceX = endCoords.x - startCoords.x;
}
if (ordinate) {
distanceY = +_$el.attr('data-y') + (endCoords.y - startCoords.y);
}
if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) {
_$el.css({
transform: 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'
});
}
}
});
$object.dataL.$item.on('touchend.rwd-container', function () {
if ($object.dataL.$cont.hasClass('rwd-zoomed')) {
if (isMoved) {
isMoved = false;
$object.touchendZoom(startCoords, endCoords, abscissa, ordinate);
}
}
});
};
Modul.prototype.initThumbs = function() {
var $object = this;
if (this.dataL.modulSettings.thumbnail === 'true' && this.dataL.$items.length > 1) {
if (this.dataL.modulSettings.showByDefault) {
setTimeout(function(){
$object.dataL.$cont.addClass('rwd-thumb-open');
}, 100);
}
this.buildThumbs();
this.dataL.effectsSupport() && this.enableThumbDrag();
this.activatedThumbs = false;
if ($object.dataL.modulSettings.toogleThumb) {
$object.$thumbCont.append(' ');
$object.dataL.$cont.find('.rwd-toggle-thumb').on('click.rwd-container', function() {
$object.dataL.$cont.toggleClass('rwd-thumb-open');
});
}
}
$('.rwd-container .rwd-thumb-item').css({
background: '#' + this.dataL.modulSettings.thumbsOverlayColor
});
$('.rwd-container .rwd-thumb-item img').css({
opacity: 1 - +this.dataL.modulSettings.thumbsOverlayOpacity / 100
});
$('.rwd-thumb-cont').css({
bottom: -$object.dataL.modulSettings.thumbsHeight + 'px'
});
if (this.dataL.modulSettings.showByDefault) {
var $cont_ = $('.cont-inner'),
$thumb_ = $('.rwd-thumb-cont'),
$toolbar_ = $('.rwd-toolbar');
setTimeout(function(){
switch(hugeit_resp_lightbox_obj.hugeit_lightbox_lightboxView){
case 'view1':
switch($object.dataL.modulSettings.thumbPosition){
case '0':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 92) + 'px)',
top: '47px'
});
$thumb_.css({
bottom: '0',
backgroundColor: 'rgba(0,0,0,.9)'
});
$('.rwd-bar > *').css({
bottom: $object.dataL.modulSettings.thumbsHeight + 'px'
});
break;
case '1':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 92) + 'px)',
top: $object.dataL.modulSettings.thumbsHeight + 47 + 'px'
});
$thumb_.css({
top: '47px',
backgroundColor: 'rgba(0,0,0,.9)'
});
break;
}
break;
case 'view2':
switch($object.dataL.modulSettings.thumbPosition) {
case '0':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 92) + 'px)',
top: '45px'
});
$thumb_.css({
bottom: '45px',
backgroundColor: 'rgba(0,0,0,.9)'
});
break;
case '1':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 92) + 'px)',
top: $object.dataL.modulSettings.thumbsHeight + 45 + 'px'
});
$thumb_.css({
top: '0',
backgroundColor: 'rgba(0,0,0,.9)'
});
$toolbar_.css({
top: $object.dataL.modulSettings.thumbsHeight + 'px'
});
break;
}
break;
case 'view3':
switch($object.dataL.modulSettings.thumbPosition) {
case '0':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 92) + 'px)',
top: '47px'
});
$thumb_.css({
bottom: '0',
backgroundColor: 'white'
});
$('.rwd-title').css({
bottom: $object.dataL.modulSettings.thumbsHeight + 'px'
});
break;
case '1':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 93) + 'px)',
top: ($object.dataL.modulSettings.thumbsHeight + 48) + 'px'
});
$thumb_.css({
top: '48px',
backgroundColor: 'white'
});
break;
}
break;
case 'view4':
case 'view7':
switch($object.dataL.modulSettings.thumbPosition) {
case '0':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 92) + 'px)'
});
$thumb_.css({
bottom: '0',
backgroundColor: 'none'
});
$('.rwd-socialIcons').css({
bottom: ($object.dataL.modulSettings.thumbsHeight - 10) + 'px'
});
$('.barCont').css({
bottom: $object.dataL.modulSettings.thumbsHeight + 'px'
});
$('#rwd-counter').css({
bottom: ($object.dataL.modulSettings.thumbsHeight + 5) + 'px'
});
$('.rwd-item').css({
top: '47px'
});
break;
case '1':
$cont_.css({
height: 'calc(100% - ' + ($object.dataL.modulSettings.thumbsHeight + 90) + 'px)',
top: $object.dataL.modulSettings.thumbsHeight + 45 + 'px'
});
$thumb_.css({
top: '45px',
backgroundColor: 'none'
});
break;
}
break;
case 'view5':
case 'view6':
switch($object.dataL.modulSettings.thumbPosition) {
case '0':
$cont_.css({
height: 'calc(100% - ' + $object.dataL.modulSettings.thumbsHeight + 'px)'
});
$thumb_.css({
bottom: '0'
});
break;
case '1':
$cont_.css({
height: 'calc(100% - ' + $object.dataL.modulSettings.thumbsHeight + 'px)',
top: $object.dataL.modulSettings.thumbsHeight + 'px'
});
$thumb_.css({
top: '0'
});
break;
}
break;
}
}, 100);
}
};
Modul.prototype.buildThumbs = function() {
var $object = this,
thumbList = '',
$thumb,
html = '';
$object.dataL.$cont.addClass('rwd-has-thumb');
$object.dataL.$cont.find('.rwd-container').append(html);
$object.$thumbCont = $object.dataL.$cont.find('.rwd-thumb-cont');
$object.thumbContWidth = $object.$thumbCont.width();
$object.dataL.$cont.find('.rwd-thumb').css({
width: $object.thumbTotalWidth + 'px',
position: 'relative'
});
$object.$thumbCont.css('height', $object.dataL.modulSettings.thumbsHeight + 'px');
function getThumb(src, thumb, index) {
var isVideo = $object.dataL.isVideo(src, index) || {};
var thumbImg;
var vimeoId = '';
if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) {
if (isVideo.youtube) {
thumbImg = '//img.youtube.com/vi/' + isVideo.youtube[1] + '/1.jpg';
} else if (isVideo.vimeo) {
thumbImg = '//i.vimeocdn.com/video/error_100x75.jpg';
vimeoId = isVideo.vimeo[1];
} else if (isVideo.dailymotion) {
thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[2];
}
} else {
thumbImg = thumb;
}
thumbList += '';
vimeoId = '';
}
$object.dataL.$items.each(function(i) {
getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).find('img').attr('src'), i);
});
$object.dataL.$cont.find('.rwd-thumb').html(thumbList);
$thumb = $object.dataL.$cont.find('.rwd-thumb-item');
$thumb.each(function() {
var $this = $(this);
var vimeoVideoId = $this.attr('data-vimeo-id');
if (vimeoVideoId) {
$.getJSON('//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=?', {
format: 'json'
}, function(data) {
$this.find('img').attr('src', data[0]['thumbnail_small']);
});
}
});
$thumb.eq($object.dataL.index).addClass('active');
$object.dataL.$element.on('onBeforeSlide.rwd-container', function() {
$thumb.removeClass('active');
$thumb.eq($object.dataL.index).addClass('active');
});
$thumb.on('click.rwd-container touchend.rwd-container', function() {
var _$this = $(this);
setTimeout(function() {
if ($object.activatedThumbs || !$object.dataL.effectsSupport()) {
$object.dataL.index = _$this.index();
$object.dataL.slide($object.dataL.index, false, true);
$('.rwd-thumb').removeClass('thumb_move');
}
}, 50);
});
$object.dataL.$element.on('onBeforeSlide.rwd-container', function() {
$object.animateThumb($object.dataL.index);
});
$(window).on('resize.rwd-container.thumb orientationchange.rwd-container.thumb', function() {
setTimeout(function() {
$object.animateThumb($object.dataL.index);
$object.thumbContWidth = $object.$thumbCont.width();
}, 200);
});
};
Modul.prototype.animateThumb = function(index) {
var $thumb = this.dataL.$cont.find('.rwd-thumb'),
position = (this.thumbContWidth / 2) - (this.dataL.modulSettings.thumbsWidth / 2);
this.left = ((this.dataL.modulSettings.thumbsWidth + this.dataL.modulSettings.thumbMargin) * index - 1) - position;
if (this.left > (this.thumbTotalWidth - this.thumbContWidth)) {
this.left = this.thumbTotalWidth - this.thumbContWidth;
}
if (this.left < 0) {
this.left = 0;
}
if (!$thumb.hasClass('on')) {
this.dataL.$cont.find('.rwd-thumb').css('transition-duration', this.dataL.modulSettings.speed + 'ms');
}
if (!this.dataL.effectsSupport()) {
$thumb.animate({
left: -this.left + 'px'
}, this.dataL.modulSettings.speed);
}
if(!$('.rwd-thumb').hasClass('thumb_move')){
this.dataL.$cont.find('.rwd-thumb').css({
transform: 'translate3d(-' + (this.left) + 'px, 0px, 0px)'
});
}
};
Modul.prototype.enableThumbDrag = function() {
var $object = this,
startCoords = 0,
endCoords = 0,
isDraging = false,
isMoved = false,
tempLeft = 0,
$left_ = ((this.dataL.modulSettings.thumbsWidth + this.dataL.modulSettings.thumbMargin) * $object.dataL.index - 1) - (this.thumbContWidth / 2) - (this.dataL.modulSettings.thumbsWidth / 2);
$('.rwd-thumb').attr('data-left', $left_);
$object.dataL.$cont.find('.rwd-thumb').on('mousedown.rwd-container.thumb', function(e) {
if ($object.thumbTotalWidth > $object.thumbContWidth) {
e.preventDefault();
startCoords = e.pageX;
isDraging = true;
$object.dataL.$cont.scrollLeft += 1;
$object.dataL.$cont.scrollLeft -= 1;
$object.activatedThumbs = false;
}
});
$(window).on('mousemove.rwd-container.thumb', function(e) {
if (isDraging) {
tempLeft = +$('.rwd-thumb').attr('data-left'); isMoved = true;
endCoords = e.pageX;
if(Math.abs(endCoords - startCoords) > 0 && $('.rwd-cont').hasClass('rwd-show-autoplay')){
$('.rwd-thumb').addClass('thumb_move');
}
tempLeft = tempLeft - (endCoords - startCoords);
if (tempLeft > ($object.thumbTotalWidth - $object.thumbContWidth)) {
tempLeft = $object.thumbTotalWidth - $object.thumbContWidth;
}
if (tempLeft < 0) {
tempLeft = 0;
}
$object.dataL.$cont.find('.rwd-thumb').css({
transform: 'translate3d(-' + (tempLeft) + 'px, 0px, 0px)'
});
}
});
$(window).on('mouseup.rwd-container.thumb', function() {
if (isMoved) {
isMoved = false;
$('.rwd-thumb').attr('data-left', tempLeft);
} else {
$object.activatedThumbs = true;
}
if (isDraging) {
isDraging = false;
}
});
};
Modul.prototype.destroy = function () {
var $object = this;
$(window).off('.rwd-container.zoom');
$('.rwd-cont').removeClass('rwd-zoomed');
clearTimeout($object.zoomabletimeout);
$object.zoomabletimeout = false;
if (hugeit_resp_lightbox_obj.hugeit_lightbox_thumbs === 'true') {
$(window).off('resize.rwd-container.thumb orientationchange.rwd-container.thumb keydown.rwd-container.thumb');
$('.rwd-cont').removeClass('rwd-has-thumb');
$('.cont-inner').css({
height: '100%'
});
}
$object.exitFullscreen();
$(document).off('fullscreenchange.rwd-container webkitfullscreenchange.rwd-container mozfullscreenchange.rwd-container MSFullscreenChange.rwd-container');
};
$.fn.lightbox.lightboxModul.modul = Modul;
var WaterMark = function (element) {
this.element = element;
this.settings = $.extend({}, this.constructor.defaults);
this.init();
};
WaterMark.defaults = {
imgSrc: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_img_src_new,
text: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_text,
textColor: '#' + hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_textColor,
textFontSize: +hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_textFontSize,
containerBackground: hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_container_bg_color,
containerWidth: +hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_containerWidth,
position: 'pos' + hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_position_new,
opacity: +hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_opacity / 100,
margin: +hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_margin,
done: function (imgURL) {
this.dataset.src = imgURL;
}
};
WaterMark.prototype.init = function () {
var $object = this,
$elem = $object.element,
$settings = $object.settings,
wmData = {},
imageData = {};
var WatermarkImage = jQuery(' ');
WatermarkImage.attr('src', $object.settings.imgSrc);
WatermarkImage.css('display', 'none').attr('id', 'huge_it_watermark_img_sample');
if (!jQuery('body').find('#huge_it_watermark_img_sample').length) {
jQuery('body').append(WatermarkImage);
}
wmData = {
imgurl: $settings.imgSrc,
type: 'jpeg'
};
imageData = {
imgurl: $elem.dataset.imgsrc
};
var defer = $.Deferred();
$.when(defer).done(function (imgObj) {
imageData.$wmObject = imgObj;
$object.imgurltodata(imageData, function (dataURL) {
$settings.done.call($elem, dataURL);
});
});
if ($settings.text !== '') {
wmData.imgurl = $object.textwatermark();
}
$object.imgurltodata(wmData, function (imgObj) {
defer.resolve(imgObj);
});
};
WaterMark.prototype.textwatermark = function () {
var $object = this,
$settings,
canvas,
context,
$width,
$height;
$settings = $object.settings;
canvas = document.createElement('canvas');
context = canvas.getContext('2d');
$width = $settings.containerWidth;
$height = $settings.textFontSize;
canvas.width = $width;
canvas.height = $height;
context.fillStyle = $settings.containerBackground;
context.fillRect(0, 0, $width, $height);
context.fillStyle = $settings.textColor;
context.textAlign = 'center';
context.font = '500 ' + $settings.textFontSize + 'px Sans-serif';
context.fillText($settings.text, ($width / 2), ($height - 5));
return canvas.toDataURL();
};
WaterMark.prototype.imgurltodata = function (data, callback) {
var $object = this,
$settings = $object.settings,
img;
img = new Image();
img.setAttribute('crossOrigin', 'anonymous');
img.onload = function () {
var canvas = document.createElement('canvas'),
context = canvas.getContext('2d'),
$imgWidth = this.width,
$imgHeight = this.height;
if (data.$wmObject) {
if (data.width !== 'auto' && data.height === 'auto' && data.width < $imgWidth) {
$imgHeight = $imgHeight / $imgWidth * data.width;
$imgWidth = data.width;
} else if (data.width === 'auto' && data.height !== 'auto' && data.height < $imgHeight) {
$imgWidth = $imgWidth / $imgHeight * data.height;
$imgHeight = data.height;
} else if (data.width !== 'auto' && data.height !== 'auto' && data.width < $imgWidth && data.height < $imgHeight) {
$imgWidth = data.width;
$imgHeight = data.height;
}
}
canvas.width = $imgWidth;
canvas.height = $imgHeight;
/*if (data.type === 'jpeg') {
context.fillStyle = '#ffffff';
context.fillRect(0, 0, $imgWidth, $imgHeight);
}*/
context.drawImage(this, 0, 0, $imgWidth, $imgHeight);
if (data.$wmObject) {
var $opacity = +hugeit_gen_resp_lightbox_obj.hugeit_lightbox_watermark_containerOpacity / 100;
if ($opacity >= 0 && $opacity <= 1) {
//context.globalAlpha = $settings.opacity;
context.globalAlpha = $opacity;
}
var $wmWidth,
$wmHeight,
pos = $settings.margin,
$x, $y;
if ($settings.text !== '') {
$wmWidth = data.$wmObject.width;
$wmHeight = data.$wmObject.height;
}
else {
$wmWidth = $settings.containerWidth;
$wmHeight = (jQuery('img#huge_it_watermark_img_sample').prop('naturalHeight') * $wmWidth) / jQuery('img#huge_it_watermark_img_sample').prop('naturalWidth');
}
switch ($settings.position) {
case 'pos1':
$x = pos;
$y = pos;
break;
case 'pos2':
$x = $imgWidth / 2 - $wmWidth / 2;
$y = pos;
break;
case 'pos3':
$x = $imgWidth - $wmWidth - pos;
$y = pos;
break;
case 'pos4':
$x = pos;
$y = $imgHeight / 2 - $wmHeight / 2;
break;
case 'pos5':
$x = $imgWidth / 2 - $wmWidth / 2;
$y = $imgHeight / 2 - $wmHeight / 2;
break;
case 'pos6':
$x = $imgWidth - $wmWidth - pos;
$y = $imgHeight / 2 - $wmHeight / 2;
break;
case 'pos7':
$x = pos;
$y = $imgHeight - $wmHeight - pos;
break;
case 'pos8':
$x = $imgWidth / 2 - $wmWidth / 2;
$y = $imgHeight - $wmHeight - pos;
break;
case 'pos9':
$x = $imgWidth - $wmWidth - pos;
$y = $imgHeight - $wmHeight - pos;
break;
default:
$x = $imgWidth - $wmWidth - pos;
$y = $imgHeight - $wmHeight - pos;
}
context.drawImage(data.$wmObject, $x, $y, $wmWidth, $wmHeight);
}
var dataURL = canvas.toDataURL('image/' + data.type);
if (typeof callback === 'function') {
if (data.$wmObject) {
callback(dataURL);
} else {
var $wmNew = new Image();
$wmNew.src = dataURL;
callback($wmNew);
}
}
canvas = null;
};
img.src = data.imgurl;
};
$.fn['watermark'] = function () {
return this.each(function () {
if (!$.data(this, 'watermark')) {
$.data(this, 'watermark', new WaterMark(this));
}
});
};
})(jQuery);