/[drupal]/contributions/modules/thickbox/thickbox_auto.js
ViewVC logotype

Contents of /contributions/modules/thickbox/thickbox_auto.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Fri May 2 15:43:05 2008 UTC (18 months, 3 weeks ago) by frjo
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.5: +25 -23 lines
File MIME type: text/javascript
First commit for Drupal 6. Thanks to patches from Greg Hines and btsukuda.
1 // $Id: thickbox_auto.js,v 1.5 2007/05/23 06:00:39 frjo Exp $
2
3 /**
4 * ATTENTION: this script has to be loaded _before_ thickbox.js
5 * Contributed by user kleingeist.
6 */
7 if (Drupal.jsEnabled) {
8 $(document).ready(function() {
9
10 // 1. "mark" the category overview pictures.
11 $("ul.galleries a > img.image.image-thumbnail").parent().addClass("category");
12
13 // 2. Group the images in specific contexts,
14
15 // find all the nodes,
16 $(".node .content").each(function(i) {
17 var group = "node-g" + i;
18 TB_drupal_rewrite(this, group);
19 });
20
21 // find the categories.
22 $("ul.images").each(function(i) {
23 var group = "gallery-g" + i;
24 TB_drupal_rewrite(this, group);
25 });
26
27 // 3. Rewrite the remaining images without grouping.
28 TB_drupal_rewrite(document, null);
29 });
30 }
31
32 function TB_drupal_rewrite(context, group) {
33 // Process only images, that have not been rewritten (.thickbox) and that are not categories.
34 $("a > img.image.image-thumbnail", context).parent().not(".thickbox").not(".category").each(function(i) {
35 var img = $(this).children("img");
36 var title = $(this).attr("title") || img.attr("title") || img.attr("alt") || null;
37
38 /**
39 * ATTENTION: Until the derivate Bug (http://drupal.org/node/125610) is fixed,
40 * the script should allways use the original picture ("true || ").
41 */
42 if (thickbox_derivative == "original") {
43 var href = img.attr("src").replace(".thumbnail", "");
44 }
45 else {
46 var href = img.attr("src").replace(".thumbnail", "." + thickbox_derivative);
47 }
48
49 // Finally rewrite the link and wait for thickbox.js to apply the effects.
50 $(this).attr({href: href, title: title, rel: group});
51 $(this).addClass("thickbox");
52 });
53 }

  ViewVC Help
Powered by ViewVC 1.1.2