make shm-thumb use consistent across themes, with data-tags and data-post-id

This commit is contained in:
Shish 2012-08-15 20:42:56 +01:00
parent 8c39c29528
commit 6394cd8100
7 changed files with 20 additions and 42 deletions

View file

@ -107,6 +107,10 @@ ui-* cookies are for the client-side scripts only; in some configurations
shm-* CSS classes are for javascript to hook into; if you're customising
themes, be careful with these, and avoid styling them
- shm-thumb = outermost element of a thumbnail
- data-tags
- data-post-id
http://shimmie.shishnet.org/doc/
Please tell me if those docs are lacking in any way, so that they can be

View file

@ -54,9 +54,9 @@ class BaseThemelet {
$tsize = get_thumbnail_size($image->width, $image->height);
}
return '<a href="'.$h_view_link.'" class="thumb" data-tags="'.$h_tags.'">'.
'<img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" class="lazy" data-original="'.$h_thumb_link.'" src="'.$base.'/lib/static/grey.gif">'.
'<noscript><img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" src="'.$h_thumb_link.'"></noscript>'.
return "<a href='$h_view_link' class='thumb shm-thumb' data-tags='$h_tags' data-post-id='$i_id'>".
"<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' class='lazy' data-original='$h_thumb_link' src='$base/lib/static/grey.gif'>".
"<noscript><img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'></noscript>".
"</a>\n";
}

View file

@ -1,16 +1,10 @@
$(function() {
var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" ");
var themecheck = $(".thumb[data-tags]").parent().attr('class');
var needs_refresh = false;
for(i=0; i<blocked_tags.length; i++) {
var tag = blocked_tags[i];
if(tag) {
if(themecheck == "thumbblock") {
$(".thumb[data-tags~='"+tag+"']").parent().hide();
$(".thumb[data-tags~='"+tag+"']").parent().height(0); //required for lite theme
}else{
$(".thumb[data-tags~='"+tag+"']").hide();
}
$(".shm-thumb[data-tags~='"+tag+"']").hide();
needs_refresh = true;
}
}

View file

@ -1,17 +1,3 @@
function find_thumb_link_containers () {
var post_link = "a[href*='/post/view/']";
var has_thumb_img = ":has(img[src*='/thumb/'])";
var list = $( post_link + has_thumb_img ).parent();
if (list) { return list; }
has_thumb_img = ":has(img[src*='_thumbs/'])";
list = $( post_link + has_thumb_img ).parent();
return list;
}
function toggle_tag( button, id ) {
id += ":";
var list = $('#mass_tagger_ids');
@ -37,21 +23,18 @@ function remove_mass_tag_id( button, list, id, string ) {
}
function activate_mass_tagger ( image_link ) {
find_thumb_link_containers().each(
$(".shm-thumb").each(
function ( index, block ) {
add_mass_tag_button( block, image_link );
}
);
$('#mass_tagger_controls').attr( 'style', 'display:block' );
$('#mass_tagger_activate').attr( 'style', 'display:none' );
$('#mass_tagger_controls').show();
$('#mass_tagger_activate').hide();
return false;
}
function add_mass_tag_button ( block, image_link ) {
var id = get_image_id( block );
var id = $(block).data("post-id");
var button = create_mass_tag_button( id, image_link );
$(block).append( button );
@ -59,13 +42,6 @@ function add_mass_tag_button ( block, image_link ) {
return;
}
function get_image_id ( block ) {
var link = $(block).children(":first").attr('href');
var id = link.split('/').pop();
return id;
}
function create_mass_tag_button ( id, image_link ) {
var img = $('<img />');
img.attr( "src", image_link+'/ext/mass_tagger/toggle.gif' );

View file

@ -5,6 +5,8 @@ class Themelet extends BaseThemelet {
$h_view_link = make_link("post/view/{$image->id}", $query);
$h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip());
$i_id = int_escape($image->id);
$h_tags = strtolower($image->get_tag_list());
// If file is flash or svg then sets thumbnail to max size.
if($image->ext == 'swf' || $image->ext == 'svg') {
@ -14,7 +16,7 @@ class Themelet extends BaseThemelet {
$tsize = get_thumbnail_size($image->width, $image->height);
}
return "<a href='$h_view_link'><img title='$h_tip' alt='$h_tip' ".
return "<a href='$h_view_link' class='shm-thumb' data-tags='$h_tags' data-post-id='$i_id'><img title='$h_tip' alt='$h_tip' ".
"width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link' /></a>";
}

View file

@ -9,6 +9,8 @@ class Themelet extends BaseThemelet {
$h_view_link = make_link("post/view/{$image->id}", $query);
$h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip());
$i_id = int_escape($image->id);
$h_tags = strtolower($image->get_tag_list());
// If file is flash or svg then sets thumbnail to max size.
if($image->ext == 'swf' || $image->ext == 'svg') {
@ -18,7 +20,7 @@ class Themelet extends BaseThemelet {
$tsize = get_thumbnail_size($image->width, $image->height);
}
return "<a class='thumb' href='$h_view_link'><img title='$h_tip' alt='$h_tip' ".
return "<a href='$h_view_link' class='thumb shm-thumb' data-tags='$h_tags' data-post-id='$i_id'><img title='$h_tip' alt='$h_tip' ".
"width='{$tsize[0]}' height='{$tsize[1]}' src='$h_thumb_link' /></a>";
}

View file

@ -21,8 +21,8 @@ class Themelet extends BaseThemelet {
$tsize = get_thumbnail_size($image->width, $image->height);
}
return '<center><div class="thumbblock">'.
'<a href="'.$h_view_link.'" class="thumb" data-tags="'.$h_tags.'">'.
return '<center class="shm-thumb" data-tags="'.$h_tags.'" data-post-id="'.$i_id.'"><div class="thumbblock">'.
'<a href="'.$h_view_link.'" class="thumb">'.
'<img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" class="lazy" data-original="'.$h_thumb_link.'" src="'.$base.'/lib/static/grey.gif">'.
'<noscript><img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" src="'.$h_thumb_link.'"></noscript>'.
"</a></div></center>\n";