Nokita Kaze 2014-12-26 09:45:36 +03:00
parent fbe0b698c2
commit 6777d8b241
5 changed files with 68 additions and 50 deletions

View File

@ -47,6 +47,9 @@
"option_fancybox_bind_images_to_one_flow": {
"message": "Bind all images from fancybox to one flow"
},
"option_fancybox_smart_hints": {
"message": "Smart hints for images in fancybox gallery"
},
"option_images_load_original": {
"message": "Load original images instead of thumbnails"
},

View File

@ -47,6 +47,9 @@
"option_fancybox_bind_images_to_one_flow": {
"message": "Связать все картинки в одну галерею"
},
"option_fancybox_smart_hints": {
"message": "Включить умные описания для картинок при скроллинге галереи"
},
"option_images_load_original": {
"message": "Загружать оригиналы вместо миниатюр"
},

View File

@ -108,64 +108,26 @@ $(document).ready(function() {
$('.post-content .text').each(function() {
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'one_flow_gallery');
});
}else{
$('.post-content .text').each(function(idxPost) {
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'post' + idxPost);
});
}
// Images
if (options.option_fancybox_images.value == true) {
if (options.option_fancybox_bind_images_to_one_flow.value !== true) {
// Linking images in posts to the galleries
$('.post-content .text').each(function(idxPost) {
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'post' + idxPost);
});
}
// Init fancybox
$('.postimg:not(.youtube)').fancybox({
type: 'image'
});
}
// Правим хинт в FancyBox
$('.post').each(function() {
var all_post_images = $(this).find('.postimg');
if (all_post_images.length == 0) {
return;
}
var tags = $(this).find('div.tags a.tag');
var hint_text = '';// Текст для хинта в FancyBox
// Сначала теги
for (var i = 0; i < tags.length; i++) {
var tag_name = $(tags[i]).html().toLowerCase();
hint_text += ' ' + tag_name;
}
// Потом текст
var textcontent = $(this).find('.text-content');
if (textcontent.length > 0) {
textcontent = textcontent[0];
for (var i = 0; i < textcontent.childNodes.length; i++) {
var current_child_node = textcontent.childNodes[i];
if ((current_child_node.nodeName !== 'P') && (current_child_node.nodeName !== '#text')) {
continue;
}
var a = $(current_child_node).find('a.postimg');
if (a.length > 0) {
continue;
}
var tmp_str = current_child_node.textContent.replace(/(\n(\r)?)/g, ' ');
tmp_str = tmp_str.replace("\t", " ");
hint_text += ' ' + tmp_str;
}
}
// Режем
hint_text = hint_text.replace(new RegExp(' {2,}'), ' ').replace(new RegExp(' +$'), '').substr(1);
if (hint_text.length > 140) {
hint_text = hint_text.substr(0, 140 - 3) + '...';
}
all_post_images.attr('data-fancybox-title', hint_text);
});
// Правим хинты у фансибокса
if (options.option_fancybox_smart_hints.value == true) {
fancybox_set_smart_hints();
} else {
$('.post .postimg').attr('data-fancybox-title', ' ');
}
// Videos
if (options.option_fancybox_videos.value == true) {
@ -675,7 +637,7 @@ function parse_webm(current_options) {
if (n = href.match(new RegExp('\\.webm(\\?.+)?$', 'i'))) {
var player = document.createElement('video');
// @todo Там может быть не vp8+vorbis
// Там может быть не vp8+vorbis, но мы этого никак не узнаем
$(player).html('<source src="' + href + '" type=\'video/webm; codecs="vp8, vorbis"\' />').attr('controls', 'controls').css({
'display': 'block',
'max-width': '95%'
@ -1055,3 +1017,49 @@ function parse_coub_links(current_options) {
}
});
}
// Правим хинт в FancyBox
function fancybox_set_smart_hints(){
$('.post').each(function() {
var all_post_images = $(this).find('.postimg');
if (all_post_images.length == 0) {
return;
}
var tags = $(this).find('div.tags a.tag');
var hint_text = '';// Текст для хинта в FancyBox
// Сначала теги
for (var i = 0; i < tags.length; i++) {
var tag_name = $(tags[i]).html().toLowerCase();
hint_text += ' ' + tag_name;
}
// Потом текст
var textcontent = $(this).find('.text-content');
if (textcontent.length > 0) {
textcontent = textcontent[0];
for (var i = 0; i < textcontent.childNodes.length; i++) {
var current_child_node = textcontent.childNodes[i];
if ((current_child_node.nodeName !== 'P') && (current_child_node.nodeName !== '#text')) {
continue;
}
var a = $(current_child_node).find('a.postimg');
if (a.length > 0) {
continue;
}
var tmp_str = current_child_node.textContent.replace(/(\n(\r)?)/g, ' ');
tmp_str = tmp_str.replace("\t", " ");
hint_text += ' ' + tmp_str;
}
}
// Режем
hint_text = hint_text.replace(new RegExp(' {2,}'), ' ').replace(new RegExp(' +$'), '').substr(1);
if (hint_text.length > 140) {
hint_text = hint_text.substr(0, 140 - 3) + '...';
}
all_post_images.attr('data-fancybox-title', hint_text);
});
}

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Point+",
"version": "1.17.4",
"version": "1.18.0",
"default_locale": "ru",
"author": "__MSG_ext_author__",
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",

View File

@ -36,6 +36,10 @@
<div class="option-node">
<input type="checkbox" class="option-boolean" id="option-fancybox-bind-images-to-one-flow"><label for="option-fancybox-bind-images-to-one-flow" data-i18n="option_fancybox_bind_images_to_one_flow"></label>
</div>
<div class="option-node">
<input type="checkbox" class="option-boolean" id="option-fancybox-smart-hints"><label for="option-fancybox-smart-hints" data-i18n="option_fancybox_smart_hints"></label>
</div>
</div>
<div class="option-node">