Версия 14:10, 19 июня 2015 | | Версия 16:48, 19 июня 2015 |
Строка 59: | | Строка 59: |
| | | | |
| $('a#popupImage-left').click(function(index) { | | | $('a#popupImage-left').click(function(index) { |
? | $('#popupImage').attr('src',''); | | + | alert('1'); |
? | var srcStr = $(this).children('img').attr('src'); //Адрес картинки | | + | |
? | if(srcStr.indexOf('thumb/')+1>0) { | | + | |
? | srcStr = srcStr.replace(/thumb\//gi, ''); | | + | |
? | srcStr = srcStr.substring(0, srcStr.lastIndexOf("/")); | | + | |
? | } | | + | |
? | | | + | |
? | $('#popupImageWindow table').css('background-image', 'url('+imageLoaderUrl+')'); | | + | |
? | $('#popupImage').width('1px'); $('#popupImage').height('1px'); | | + | |
? | $('#popupImage').attr('src',srcStr); | | + | |
? | $('#popupImageButtons a#openImageFile').attr('href', $(this).attr('href')); | | + | |
? | | | + | |
? | var titleStr = ''; //Подпись | | + | |
? | if($(this).next('div.thumbcaption').length>0) {titleStr=$(this).next('div.thumbcaption').text().trim();} | | + | |
? | else if($(this).parent().parent().parent().children('div.gallerytext').length>0){titleStr=$(this).parent().parent().parent().children('div.gallerytext').text().trim();} //слабоумие и отвага | | + | |
? | | | + | |
? | if(titleStr.trim().length > 0) {$('#popupImageInfo').text(titleStr.trim());} else {$('#popupImageInfo').text('');} | | + | |
? | | | + | |
? | $('#popupImageWrapper').hide(); $('#popupImageWindow').show(); $('#popupImageButtons').show(); | | + | |
| return false; | | | return false; |
| }); | | | }); |
| | | | |
| }; | | | }; |
Версия 16:48, 19 июня 2015
/* добавляет структуру для просмотра увеличенных изображений без перехода на другую страницу */
function addImagePopupWindow() {
$('body').append('<div id="popupImageWindow"><table><tr><td style="vertical-align: middle;">'+
'<div id="popupImageWrapper" style="position: relative; display: inline-block;">'+
'<img id="popupImage" src="" /><img src="//wikicdn.wargaming.net/images/b/bd/Close.png" class="closeBtn">'+
'<a style="display: inline; width: 35%; left: 0px; position: absolute; height: 100%; top: 0px;" href="javascript:;" id="popupImage-left">'+
'<span id="popupImage-left-ico" style="cursor: pointer; top: 50%; position: absolute; left: 20px; background: transparent url(\'//wiki.gcdn.co/images/f/f1/Prev.png\') repeat scroll 0% 0%; height: 42px; width: 42px;"></span>'+
'</a>'+
'<a style="display: inline; width: 35%; right: 0px; position: absolute; height: 100%; top: 0px;" href="javascript:;" id="popupImage-right">'+
'<span id="popupImage-right-ico" style="cursor: pointer; top: 50%; position: absolute; right: 20px; background: transparent url(\'//wiki.gcdn.co/images/c/c4/Next.png\') repeat scroll 0% 0%; height: 42px; width: 42px;"></span>'+
'</a>'+
'<div id="popupImageInfo"></div></div>'+
'</td></tr></table></div>'+
'<div id="popupImageButtons"><a id="openImageFile" href="#">Файл</a></div>');
}
/* добавляет функционал просмотра увеличенных изображений без перехода на другую страницу */
function addImagePopups() {
if(localStorage.oImagePopupOn==0) return true; // для дебага
addImagePopupWindow();
$('a.image').not($('.js-vehicles_by_types a.image')).click(function(index) {
$('#popupImage').attr('src','');
var srcStr = $(this).children('img').attr('src'); //Адрес картинки
if(srcStr.indexOf('thumb/')+1>0) {
srcStr = srcStr.replace(/thumb\//gi, '');
srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));
}
$('#popupImageWindow table').css('background-image', 'url('+imageLoaderUrl+')');
$('#popupImage').width('1px'); $('#popupImage').height('1px');
$('#popupImage').attr('src',srcStr);
$('#popupImageButtons a#openImageFile').attr('href', $(this).attr('href'));
var titleStr = ''; //Подпись
if($(this).next('div.thumbcaption').length>0) {titleStr=$(this).next('div.thumbcaption').text().trim();}
else if($(this).parent().parent().parent().children('div.gallerytext').length>0){titleStr=$(this).parent().parent().parent().children('div.gallerytext').text().trim();} //слабоумие и отвага
if(titleStr.trim().length > 0) {$('#popupImageInfo').text(titleStr.trim());} else {$('#popupImageInfo').text('');}
$('#popupImageWrapper').hide(); $('#popupImageWindow').show(); $('#popupImageButtons').show();
return false;
});
// При загрузке картинки
$('#popupImage').load(function() {
$('#popupImage').width(''); $('#popupImage').height('');
$(this).css('max-width', (self.innerWidth-100)+'px'); $(this).css('max-height',(self.innerHeight-100)+'px');
$('#popupImageWindow table').css('background-image', '');
$('#popupImageWrapper').show();
if($('#popupImageInfo').text().trim().length > 0) {$('#popupImageInfo').show();} else {$('#popupImageInfo').hide();}
});
//Закрыть попап
$('#popupImageWindow').click(function(index) {
$(this).hide(); $('#popupImageButtons').hide();
$('#popupImageButtons a').attr('href', '#'); $('#popupImageInfo').text('');$('#popupImage').attr('src','');
});
$('a#popupImage-left').click(function(index) {
alert('1');
return false;
});
};