- Автор темы
- #1
Для просмотра ссылки Войди или Зарегистрируйся
скажите это самописная галерея или где-то можно скачать
скажите это самописная галерея или где-то можно скачать
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
<script type="text/javascript">
<!--//
var list_p = $('list').get('value');
var fx;
var photo_width = 79;
//var photo_pos = 10;
var photo_pos = $('photo_pos').get('value').toInt();
var photo_id = $('curr_p').get('value').toInt();
var photos_count = $('photos_count').get('value').toInt();
var photos_i_count = $('photos_i_count').get('value').toInt();
var photos_p_count = $('photos_p_count').get('value').toInt();
var photos_hidden_count = $('photos_hidden_count').get('value').toInt();
var photos_visible_count = $('photos_visible_count').get('value').toInt();
var photos_all_count_left = $('photos_hidden_count_left').get('value').toInt();
var photos_visible_count_left = $('photos_visible_count_left').get('value').toInt();
var photos_hidden_count_left = photos_all_count_left - photos_visible_count_left;
var photos_all_count_right = $('photos_hidden_count_right').get('value').toInt();
var photos_visible_count_right = $('photos_visible_count_right').get('value').toInt();
var photos_hidden_count_right = photos_all_count_right - photos_visible_count_right;
var photos_hidden_start = $('photos_hidden_start').get('value').toInt();
var photos_visible_start = $('photos_visible_start').get('value').toInt();
var photos_hidden_end = $('photos_hidden_end').get('value').toInt();
var photos_visible_end = $('photos_visible_end').get('value').toInt();
var photos_half_all = $('photos_half_hidden').get('value').toInt();
var photos_half_visible = $('photos_half_visible').get('value').toInt();
var photos_half_hidden = photos_half_all - photos_half_visible;
var hidden_position = -1 * (photos_all_count_left - photos_visible_count_left) * 79;
var photos_hidden_start_current = photos_hidden_start;
var photos_hidden_end_current = photos_hidden_end;
var to_left = 0;
var to_right = 0;
var scroll_timeout = false; // флаг разрешения прокрутки списка
var timeout_id = null;
var old_form = 0;
function addImages(user, start, count) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/add-images/',
onSuccess: function(responseJSON) {
if (responseJSON && responseJSON['script']) {
eval(responseJSON['script']);
}
},
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'format': 'json', 'user': user, 'start': start, 'count': count});
}
function draw_icons() {
var hidden_start = photos_hidden_start;
var hidden_end = photos_hidden_end;
var hidden_start_current = photos_hidden_start_current;
var hidden_end_current = photos_hidden_end_current;
to_left = 0;
to_right = 0;
// меняем текущую позицию прездагруженных фото.
photos_hidden_end_current = hidden_end;
photos_hidden_start_current = hidden_start;
// Получение списка элементов
var list_items = $(list_p).getElements('li');
count_end = hidden_end_current - hidden_end;
count_start = hidden_start_current - hidden_start;
// Справа.
if (hidden_end < hidden_end_current) {
// Удаляем фотки справа от hidden_end + 1 до hidden_end_current.
count = hidden_end_current - hidden_end;
for (i = 0; i < count; i++) {
// Удаляем предзагруженные фотки с конца.
$('li_i_' + (hidden_end + 1 + i)).destroy();
}
} else if (hidden_end > hidden_end_current) {
// Добавляем фотки справа.
count = hidden_end - hidden_end_current;
for (i = 0; i < count; i++) {
add_picture(hidden_end_current + 1 + i, false);
}
addImages(19281, hidden_end_current + 1, count);
}
// Слева.
if (hidden_start > hidden_start_current) {
// Удаляем фотки слева.
count = hidden_start - hidden_start_current;
for (i = 0; i < count; i++) {
// Удаляем предзагруженные фотки сначала.
$('li_i_' + (hidden_start_current + i)).destroy();
//if (typeof list_items[i] != "undefined") {
// list_items[i].destroy();
//}
}
hidden_position += count * photo_width;
$(list_p).setStyle('margin-left', hidden_position); // Сдвигаем слой вправо (уменьшаем).
} else if (hidden_start < hidden_start_current) {
// Добавляем фотки слева.
count = hidden_start_current - hidden_start;
for (i = 0; i < count; i++) {
add_picture(hidden_start_current -1 - i, true);
}
addImages(19281, hidden_start, count);
hidden_position -= count * photo_width;
$(list_p).setStyle('margin-left', hidden_position); // Сдвигаем слой влево (увеличиваем).
}
// Кнопушки.
if(photos_visible_start > 0) {
$('previous').setStyle('cursor', 'pointer');
$('previous').setProperty('src', 'http://images-i-2.cdn.mywed.ru/images/ico_left.gif');
} else {
$('previous').setStyle('cursor', 'default');
$('previous').setProperty('src', 'http://images-i-5.cdn.mywed.ru/images/1.gif');
}
if (photos_visible_end < photos_count - 1) {
$('next').setStyle('cursor','pointer');
$('next').setProperty('src', 'http://images-i-3.cdn.mywed.ru/images/ico_right.gif');
} else {
$('next').setStyle('cursor','default');
$('next').setProperty('src', 'http://images-i-5.cdn.mywed.ru/images/1.gif');
}
}
// функция добавления картинки с ссылкой в список "на лету".
// top - булева переменная, если установлена картинка добавляется в начало списка.
// сделать аналог - remove.
function add_picture(num, top) {
photos_hidden_count++;
var hidden_width = photo_width * photos_hidden_count;
$(list_p).style.width = hidden_width + 'px'; //установка ширины предзагруженного списка
var new_li = new Element('li',{
'id':'li_i_' + num
});
if (top) {
new_li.inject(list_p, 'top');
} else {
new_li.inject(list_p, 'bottom');
}
var new_a = new Element('a', {
'id':'a_i_' + num,
'href':'#'
});
new_a.inject(new_li);
var new_img = new Element('img', {
'id':'pict_i_' + num,
'class':((num == photo_pos) ? 'pict_i_a' : 'pict_i'),
'src':'http://images-i-5.cdn.mywed.ru/images/1.gif'
});
new_img.inject(new_a);
}
function set_picture(num, src, link) {
//$('a_i_' + num).setProperty('href', link);
$('a_i_' + num).setProperty('href', '/photographer/detail/photo/' + link + '/');
$('a_i_' + num).setProperty('onclick', 'return switchPhoto(' + link + ',1257606)');
$('pict_i_' + num).setProperty('src', src);
}
function step_left(fx) {
// если левая видимая фотка не первая, то сдвигаем блоки.
if ((photos_visible_start > 0) && (to_left < photos_i_count)) {
photos_visible_start--;
photos_visible_end--; // точно?
to_left++;
// если левая предзагруженная фотка не первая, то сдвигаем левую границу предзагруженного блока.
if ((photos_hidden_start > 0) && (photos_hidden_start > photos_visible_start - photos_half_hidden)) {
photos_hidden_start--;
}
// если правая предзагруженная фотка не совпадает с последней невидимой, то сдвигаем правую границу предзагруженного блока.
if (photos_hidden_end > photos_visible_end + photos_half_hidden) {
photos_hidden_end--;
}
// Пересчитываем количество предзагруженных фото.
photos_hidden_count = photos_hidden_end - photos_hidden_start + 1;
hidden_position += photo_width;
fx.cancel();
fx.start('margin-left', hidden_position);
}
}
function step_right(fx) {
// если правая видимая фотка не последняя, то сдвигаем блоки.
if ((photos_visible_start < photos_count - photos_i_count) && (to_right < photos_i_count)) {
photos_visible_start++;
photos_visible_end++;
to_right++;
if (photos_hidden_start < photos_visible_start - photos_half_hidden) {
photos_hidden_start++;
}
if ((photos_hidden_end < photos_count - 1) && (photos_hidden_end < photos_visible_end + photos_half_hidden)) {
photos_hidden_end++;
}
photos_hidden_count = photos_hidden_end - photos_hidden_start + 1;
hidden_position -= photo_width;
fx.cancel();
fx.start('margin-left', hidden_position);
}
}
function higlight_vote(photo_id, num, on) {
if (on == 1) {
for(i = 1; i <= num; i++) {
$('vote_photo_' + photo_id + '_' + i).className = 'vote_star_hover';
}
switch (num) {
case 1:
$('vote_comment_' + photo_id).innerHTML = 'Ужас!';
break;
case 2:
$('vote_comment_' + photo_id).innerHTML = 'Плохо';
break;
case 3:
$('vote_comment_' + photo_id).innerHTML = 'Нормально';
break;
case 4:
$('vote_comment_' + photo_id).innerHTML = 'Хорошо';
break;
case 5:
$('vote_comment_' + photo_id).innerHTML = 'Супер!';
break;
}
} else {
for(i = 1; i <= 5; i++) {
$('vote_photo_' + photo_id + '_' + i).className = 'vote_star';
}
$('vote_comment_' + photo_id).innerHTML = 'Вы еще не голосовали';
}
return false;
}
function makeVote(photo_id, num) {
var html = '';
html += "<table id=\"vote_photo_" + photo_id + "\" class=\"vote\">";
html += "<tr>";
if (num > 0) {
html += "<td id=\"vote_photo_" + photo_id + "_1\" class=\"vote_star_active\"></td>";
} else {
html += "<td id=\"vote_photo_" + photo_id + "_1\" class=\"vote_star_passive\"></td>";
}
if (num > 1) {
html += "<td id=\"vote_photo_" + photo_id + "_2\" class=\"vote_star_active\"></td>";
} else {
html += "<td id=\"vote_photo_" + photo_id + "_2\" class=\"vote_star_passive\"></td>";
}
if (num > 2) {
html += "<td id=\"vote_photo_" + photo_id + "_3\" class=\"vote_star_active\"></td>";
} else {
html += "<td id=\"vote_photo_" + photo_id + "_3\" class=\"vote_star_passive\"></td>";
}
if (num > 3) {
html += "<td id=\"vote_photo_" + photo_id + "_4\" class=\"vote_star_active\"></td>";
} else {
html += "<td id=\"vote_photo_" + photo_id + "_4\" class=\"vote_star_passive\"></td>";
}
if (num > 4) {
html += "<td id=\"vote_photo_" + photo_id + "_5\" class=\"vote_star_active\"></td>";
} else {
html += "<td id=\"vote_photo_" + photo_id + "_5\" class=\"vote_star_passive\"></td>";
}
html += "<td id=\"vote_comment_" + photo_id + "\" class=\"vote_comment\">Ваш голос принят</td>";
html += "</tr>";
html += "</table>";
$('vote_photo_' + photo_id + '_cnt').innerHTML = html;
photoVoteAdd(photo_id, num);
return false;
}
function photoVoteAdd(photoId, vote) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/photo-vote-add/',
format: 'json',
onSuccess: function(responseJSON) {
if (responseJSON && responseJSON['target'] && responseJSON['html']) {
$(responseJSON['target']).set('html', responseJSON['html']);
}
},
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'photoId': photoId, 'vote': vote});
}
function validate_photo_message_add_form() {
result = true;
if (!ValidateAsNotEmpty($('photo_message_text').value)) {
$('photo_message_text_error').style.lineHeight = '120%';
$('photo_message_text_error').innerHTML = 'Введите текст';
$('photo_message_text').focus();
result = false;
}
else {
$('photo_message_text_error').style.lineHeight = '0';
$('photo_message_text_error').innerHTML = '';
}
// messageSlider.show();
$('photo_message').setStyle('display', 'block');
$('photo_message').parentNode.setStyle('height', 'auto');
if (result == false) {
return false;
}
else
{
$('photo_message_add_submit').disabled=true;
$('photo_message_add_submit').value='Сохранение…';
return true;
}
}
function validate_photo_comment_add_form() {
result = true;
if (!ValidateAsNotEmpty($('photo_comment_text').value)) {
$('photo_comment_text_error').style.lineHeight = '120%';
$('photo_comment_text_error').innerHTML = 'Введите текст';
$('photo_comment_text').focus();
result = false;
}
else {
$('photo_comment_text_error').style.lineHeight = '0';
$('photo_comment_text_error').innerHTML = '';
}
// commentSlider.show();
if (result == false) {
return false;
}
else
{
$('photo_message_add_submit').disabled = true;
$('photo_message_add_submit').value='Сохранение…';
return true;
}
}
function get_comment_form(photo_id, message_id) {
var form = '';
if (old_form > 0) {
$('message_comment_' + old_form).innerHTML = '';
}
old_form = message_id;
form += '<form id="photo_comment_add_form" name="photo_comment_add_form" action="/photographer/reply/" method="post" onsubmit="return validate_photo_comment_add_form();" enctype="multipart/form-data">';
form += '<input type="hidden" id="photo_id" name="photo_id" value="' + photo_id + '" />';
form += '<input type="hidden" id="photo_message_id" name="photo_message_id" value="' + message_id + '" />';
form += '<input type="hidden" id="photo_comment_add_form_submit" name="photo_comment_add_form_submit" value="1" />';
form += '<table class="photo_form">';
form += '<tr>';
form += '<td colspan="2" class="field" style="padding-right: 2px;">';
form += '<textarea id="photo_comment_text" name="photo_comment_text" rows="8" onkeydown="ctrl_enter(event, \'photo_comment_add_form\');" onblur="focusMessage(0);" onfocus="focusMessage(1);">';
form += '</textarea>';
form += '<div id="photo_comment_text_error" class="error"></div>';
form += '</td>';
form += '</tr>';
form += '</table>';
form += '<div><input type="submit" id="photo_comment_add_submit" name="photo_comment_add_submit" value="Ответить" /></div>';
form += '</form>';
$('message_comment_' + message_id).innerHTML = form;
$('photo_comment_text').focus();
}
function message_toggle(focus) {
if ($('photo_message_text').disabled == true) {
$('photo_message_text').disabled = false;
$('photo_message_add_submit').disabled = false;
$('photo_message').setStyle('display', 'block');
if (typeof(focus) == 'undefined' || focus) {
$('photo_message_text').focus();
}
}
else {
hideMessage();
}
}
function hideMessage() {
$('photo_message_text').disabled = true;
$('photo_message_add_submit').disabled = true;
$('photo_message').setStyle('display', 'none');
}
function show_close_photo(id) {
$('comment-switcher').set('html', 'запретить');
}
function hide_close_photo(id) {
$('comment-switcher').set('html', 'разрешены');
}
function show_open_photo(id) {
$('comment-switcher').set('html', 'разрешить');
}
function hide_open_photo(id) {
$('comment-switcher').set('html', 'запрещены');
}
function show_visible_photographer_photo(id) {
$('visible-switcher').set('html', 'только фотографам');
}
function hide_visible_photographer_photo(id) {
$('visible-switcher').set('html', 'всем посетителям');
}
function show_visible_all_photo(id) {
$('visible-switcher').set('html', 'всем посетителям');
}
function hide_visible_all_photo(id) {
$('visible-switcher').set('html', 'только фотографам');
}
function closePhoto(photoId) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/close-photo/',
format: 'json',
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'photoId': photoId});
}
function close_photo(id) {
$$('.comment-reply').each(function(item, index) {
item.setProperty('style', 'display: none;');
});
$('add-comment').set('html', '<div style="height: 26px;"> <div>');$('comment-switch').set('html', 'Комментарии <a id="comment-switcher" class="switch2" href="javascript:void(null);" onmouseover="show_open_photo();" onmouseout="hide_open_photo();" onclick="open_photo(' + id + ');">запрещены</a>');
$('visible-switch').setStyle('visibility', 'hidden');
closePhoto(id);
}
function openPhoto(photoId) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/open-photo/',
format: 'json',
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'photoId': photoId});
}
function open_photo(id) {
$$('.comment-reply').each(function(item, index) {
item.setProperty('style', 'display: inline;');
});
$('add-comment').set('html', '<a href="javascript:void(null);" onclick="message_toggle();" class="forum_add_comment" target="_self">Комментировать</a>'); $('comment-switch').set('html', 'Комментарии <a id="comment-switcher" class="switch2" href="javascript:void(null);" onmouseover="show_close_photo();" onmouseout="hide_close_photo();" onclick="close_photo(' + id + ');"> разрешены</a>');
$('visible-switch').setStyle('visibility', 'visible');
openPhoto(id);
}
function visibleForAll(photoId) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/visible-for-all/',
format: 'json',
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'photoId': photoId});
}
function change_visible_to_all(id) {
$('visible-switch').set('html', 'и видны <a id="visible-switcher" class="switch2" href="javascript:void(null);" onmouseover="show_visible_photographer_photo();" onmouseout="hide_visible_photographer_photo();" onclick="change_visible_to_photographer(' + id + ');">всем посетителям</a>');
visibleForAll(id);
}
function visibleForPhotographer(photoId) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/visible-for-photographer/',
format: 'json',
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'photoId': photoId});
}
function change_visible_to_photographer(id) {
$('visible-switch').set('html', 'и видны <a id="visible-switcher" class="switch2" href="javascript:void(null);" onmouseover="show_visible_all_photo();" onmouseout="hide_visible_all_photo();" onclick="change_visible_to_all(' + id + ');">только фотографам</a>');
visibleForPhotographer(id);
}
function photoFavChange(photoId) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/photo-fav-change/',
format: 'json',
onSuccess: function(responseJSON) {
if (responseJSON) {
if (responseJSON['link']) {
$('photo_' + photoId).set('html', responseJSON['link']);
}
if (responseJSON['detail']) {
$('detail_photo_fav').set('html', responseJSON['detail']);
}
if (responseJSON['user_total_fav_photo_count'] && $('user_total_fav_photo_count')) {
$('user_total_fav_photo_count').set('html', responseJSON['user_total_fav_photo_count']);
}
}
},
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'photoId': photoId, 'type': 1});
}
var photoSize = 0;
function changePhotoSize(size, login, photoId) {
var jsonRequest = new Request.JSON({
url: '/ajax/photographer/change-photo-size/',
format: 'json',
onSuccess: function(responseJSON) {
if (responseJSON) {
if (responseJSON['photoSizeBig']) {
$('photo-size-big').set('html', responseJSON['photoSizeBig']);
photoSize = size;
}
if (responseJSON['photoSizeMedium']) {
$('photo-size-medium').set('html', responseJSON['photoSizeMedium']);
}
if (responseJSON['pict']) {
$('pict').set('src', responseJSON['pict']);
}
}
},
onFailure: function(xhr) {
alert('Неизвестная ошибка!');
},
}).post({'size': size, 'login': login, 'photoId': photoId});
}
//-->
</script>