From 6c054b8dba1e6a831b1662091426be472397f8c9 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Fri, 2 Jan 2015 18:53:46 +0300 Subject: [PATCH] =?UTF-8?q?*=20=D0=A1=D0=BC=D0=B0=D1=80=D1=82=20=D1=85?= =?UTF-8?q?=D0=B8=D0=BD=D1=82=20=D1=81=D1=82=D0=B0=D0=BB=20=D0=B5=D1=89?= =?UTF-8?q?=D1=91=20=D1=83=D0=BC=D0=BD=D0=B5=D0=B5!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/js/point-plus.js | 33 ++++++++++++++++++++++-------- chrome_point_plus/manifest.json | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 7da6c05..f918db5 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -1012,11 +1012,11 @@ function fancybox_set_smart_hints(){ } var tags = $(this).find('div.tags a.tag'); - var hint_text = '';// Текст для хинта в FancyBox + var default_hint_text = '';// Дефолтный текст для хинта в FancyBox, если не нашлость другого // Сначала теги for (var i = 0; i < tags.length; i++) { var tag_name = $(tags[i]).html().toLowerCase(); - hint_text += ' ' + tag_name; + default_hint_text += ' ' + tag_name; } // Потом текст @@ -1035,17 +1035,34 @@ function fancybox_set_smart_hints(){ var tmp_str = current_child_node.textContent.replace(/(\n(\r)?)/g, ' '); tmp_str = tmp_str.replace("\t", " "); - hint_text += ' ' + tmp_str; + default_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) + '...'; + // Режем текст + default_hint_text = default_hint_text.replace(new RegExp(' {2,}'), ' ').replace(new RegExp(' +$'), '').substr(1); + if (default_hint_text.length > 140) { + default_hint_text = default_hint_text.substr(0, 140 - 3) + '...'; } - all_post_images.attr('data-fancybox-title', hint_text); + // Выставляем дефолтный + all_post_images.attr('data-fancybox-title', default_hint_text); + + // А теперь перебираем по одному все картинки + var paragraphs = $(this).find('.post-content > .text > p, .post-content > .text, .text-content > p, .text-content'); + + paragraphs.each(function() { + var nodes = this.childNodes; + for (var i = 0; i < nodes.length - 2; i++) { + if ($(nodes[i]).hasClass('booru_pic')) { + if (nodes[i + 2].nodeName == '#text') { + $(nodes[i]).attr('data-fancybox-title', nodes[i + 2].textContent); + i += 2; + continue; + } + } + } + }); }); } diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json index 21a2e5f..351707b 100644 --- a/chrome_point_plus/manifest.json +++ b/chrome_point_plus/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Point+", - "version": "1.18.3", + "version": "1.18.4", "default_locale": "ru", "author": "__MSG_ext_author__", "homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",