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 shm-* CSS classes are for javascript to hook into; if you're customising
themes, be careful with these, and avoid styling them 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/ http://shimmie.shishnet.org/doc/
Please tell me if those docs are lacking in any way, so that they can be 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); $tsize = get_thumbnail_size($image->width, $image->height);
} }
return '<a href="'.$h_view_link.'" class="thumb" data-tags="'.$h_tags.'">'. 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">'. "<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>'. "<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"; "</a>\n";
} }

View file

@ -1,16 +1,10 @@
$(function() { $(function() {
var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" "); var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" ");
var themecheck = $(".thumb[data-tags]").parent().attr('class');
var needs_refresh = false; var needs_refresh = false;
for(i=0; i<blocked_tags.length; i++) { for(i=0; i<blocked_tags.length; i++) {
var tag = blocked_tags[i]; var tag = blocked_tags[i];
if(tag) { if(tag) {
if(themecheck == "thumbblock") { $(".shm-thumb[data-tags~='"+tag+"']").hide();
$(".thumb[data-tags~='"+tag+"']").parent().hide();
$(".thumb[data-tags~='"+tag+"']").parent().height(0); //required for lite theme
}else{
$(".thumb[data-tags~='"+tag+"']").hide();
}
needs_refresh = true; 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 ) { function toggle_tag( button, id ) {
id += ":"; id += ":";
var list = $('#mass_tagger_ids'); var list = $('#mass_tagger_ids');
@ -37,21 +23,18 @@ function remove_mass_tag_id( button, list, id, string ) {
} }
function activate_mass_tagger ( image_link ) { function activate_mass_tagger ( image_link ) {
$(".shm-thumb").each(
find_thumb_link_containers().each(
function ( index, block ) { function ( index, block ) {
add_mass_tag_button( block, image_link ); add_mass_tag_button( block, image_link );
} }
); );
$('#mass_tagger_controls').attr( 'style', 'display:block' ); $('#mass_tagger_controls').show();
$('#mass_tagger_activate').attr( 'style', 'display:none' ); $('#mass_tagger_activate').hide();
return false; return false;
} }
function add_mass_tag_button ( block, image_link ) { function add_mass_tag_button ( block, image_link ) {
var id = $(block).data("post-id");
var id = get_image_id( block );
var button = create_mass_tag_button( id, image_link ); var button = create_mass_tag_button( id, image_link );
$(block).append( button ); $(block).append( button );
@ -59,13 +42,6 @@ function add_mass_tag_button ( block, image_link ) {
return; 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 ) { function create_mass_tag_button ( id, image_link ) {
var img = $('<img />'); var img = $('<img />');
img.attr( "src", image_link+'/ext/mass_tagger/toggle.gif' ); 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_view_link = make_link("post/view/{$image->id}", $query);
$h_thumb_link = $image->get_thumb_link(); $h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip()); $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 file is flash or svg then sets thumbnail to max size.
if($image->ext == 'swf' || $image->ext == 'svg') { if($image->ext == 'swf' || $image->ext == 'svg') {
@ -14,7 +16,7 @@ class Themelet extends BaseThemelet {
$tsize = get_thumbnail_size($image->width, $image->height); $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>"; "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_view_link = make_link("post/view/{$image->id}", $query);
$h_thumb_link = $image->get_thumb_link(); $h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip()); $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 file is flash or svg then sets thumbnail to max size.
if($image->ext == 'swf' || $image->ext == 'svg') { if($image->ext == 'swf' || $image->ext == 'svg') {
@ -18,7 +20,7 @@ class Themelet extends BaseThemelet {
$tsize = get_thumbnail_size($image->width, $image->height); $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>"; "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); $tsize = get_thumbnail_size($image->width, $image->height);
} }
return '<center><div class="thumbblock">'. return '<center class="shm-thumb" data-tags="'.$h_tags.'" data-post-id="'.$i_id.'"><div class="thumbblock">'.
'<a href="'.$h_view_link.'" class="thumb" data-tags="'.$h_tags.'">'. '<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">'. '<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>'. '<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"; "</a></div></center>\n";