1/* $Id: auto_image_handling.js,v 1.1.4.23 2009/01/04 21:07:48 snpower Exp $ */ 2 3// Image Node Auto-Format with Auto Image Grouping. 4// Original version by Steve McKenzie. 5// Altered by Stella Power for jQuery version. 6 7function parse_url(url, param) { 8 param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 9 url = url.replace(/&/, "&"); 10 var regexS = "[\\?&]"+param+"=([^&#]*)"; 11 var regex = new RegExp(regexS); 12 var results = regex.exec(url); 13 if (results === null) { 14 return ""; 15 } 16 else { 17 return results[1]; 18 } 19} 20 21 22function lightbox2_init_triggers(classes, rel_type, custom_class) { 23 var settings = Drupal.settings.lightbox2; 24 25 var link_target = ""; 26 if (settings.node_link_target !== 0) { 27 link_target = 'target="'+ settings.node_link_target +'"'; 28 } 29 30 $("a:has("+classes+")").each(function(i) { 31 32 if ((!settings.disable_for_gallery_lists && !settings.disable_for_acidfree_gallery_lists) || (!$(this).parents("td.giAlbumCell").attr("class") && !$(this).parents(".galleries").length && !$(this).parents(".acidfree-folder").length && !$(this).parents(".acidfree-list").length) || ($(this).parents(".galleries").length && !settings.disable_for_gallery_lists) || (($(this).parents(".acidfree-folder").length || $(this).parents(".acidfree-list").length) && !sett
32ings.disable_for_acidfree_gallery_lists)) { 33 34 var child = $(this).find(classes); 35 36 // Ensure the child has a class attribute we can work with. 37 if ($(child).attr("class") && !$(this).parents("div.acidfree-video").length) { 38 39 // Set the alt text. 40 var alt = $(child).attr("alt"); 41 if (!alt) { 42 alt = ""; 43 } 44 45 // Set the image node link text. 46 var link_text = settings.node_link_text; 47 var download_link_text = settings.download_link_text; 48 49 // Set the rel attribute. 50 var rel = "lightbox"; 51 var lightframe = false; 52 if (rel_type == "lightframe_ungrouped") { 53 rel = "lightframe[]"; 54 lightframe = true; 55 } 56 else if (rel_type == "lightframe") { 57 lightframe = true; 58 } 59 else if (rel_type == "lightbox_ungrouped") { 60 rel = "lightbox[]"; 61 } 62 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 63 rel = rel_type + "[" + $(child).attr("class") + "]"; 64 } 65 66 // Set the basic href attribute - need to ensure there's no language 67 // string (e.g. /en) prepended to the URL. 68 var id = null; 69 var href = $(child).attr("src"); 70 var download = null; 71 var orig_href = $(this).attr("href"); 72 var pattern = new RegExp(settings.file_path); 73 if (orig_href.match(pattern)) { 74 var lang_pattern = new RegExp(Drupal.settings.basePath + "\\w\\w\\/"); 75 orig_href = orig_href.replace(lang_pattern, Drupal.settings.basePath); 76 } 77 var frame_href = orig_href; 78 79 // Handle flickr images. 80 if ($(child).attr("class").match("flickr-photo-img") || 81 $(child).attr("class").match("flickr-photoset-img")) { 82 href = $(child).attr("src").replace("_s.", ".").replace("_t.", ".").replace("_m.", ".").replace("_b.", "."); 83 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 84 rel = rel_type + "[flickr]"; 85 if ($(child).parents("div.block-flickr").attr("class")) { 86 id = $(child).parents("div.block-flickr").attr("id"); 87 rel = rel_type + "["+ id +"]"; 88 } 89 } 90 } 91 92 // Handle "image-img_assist_custom" images. 93 else if ($(child).attr("class").match("image-img_assist_custom")) { 94 // Image assist uses "+" signs for spaces which doesn't work for 95 // normal links. 96 orig_href = orig_href.replace(/\+/, " "); 97 href = $(child).attr("src").replace(new RegExp("\\.img_assist_custom"), ((settings.display_image_size === "")?settings.display_image_size:"."+ settings.display_image_size)); 98 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 99 rel = rel_type + "[node_images]"; 100 } 101 if (lightframe) { 102 frame_href = orig_href + "/lightbox2"; 103 } 104 } 105 106 // Handle "inline" images. 107 else if ($(child).attr("class").match("inline")) { 108 href = orig_href; 109 } 110 111 // Handle gallery2 block images. 112 else if ($(child).attr("class").match("ImageFrame_image") || $(child).attr("class").match("ImageFrame_none")) { 113 var thumb_id = parse_url(href, "g2_itemId"); 114 var new_id = parse_url(orig_href, "g2_itemId"); 115 if (new_id && thumb_id) { 116 var g2pattern = new RegExp("g2_itemId="+thumb_id); 117 var replacement = "g2_itemId="+ new_id; 118 href = href.replace(g2pattern, replacement); 119 } 120 rel = rel_type + "[gallery2]"; 121 if ($(child).parents("div.block-gallery").attr("class")) { 122 id = $(child).parents("div.block-gallery").attr("id"); 123 rel = rel_type + "["+ id +"]"; 124 } 125 } 126 127 128 // Set the href attribute. 129 else if (settings.image_node_sizes != '()' && !custom_class) { 130 href = $(child).attr("src").replace(new RegExp(settings.image_node_sizes), ((settings.display_image_size === "")?settings.display_image_size:"."+ settings.display_image_size)).replace(/(image\/view\/\d+)(\/[\w\-]*)/, ((settings.display_image_size === "")?"$1/_original":"$1/"+ settings.display_image_size)); 131 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 132 rel = rel_type + "[node_images]"; 133 if ($(child).parents("div.block-multiblock,div.block-image").attr("class")) { 134 id = $(child).parents("div.block-multiblock,div.block-image").attr("id"); 135 rel = rel_type + "["+ id +"]"; 136 } 137 } 138 download = $(child).attr("src").replace(new RegExp(settings.image_node_sizes), "").replace(/(image\/view\/\d+)(\/[\w\-]*)/, "$1/_original"); 139 if (lightframe) { 140 frame_href = orig_href + "/lightbox2"; 141 } 142 } 143 144 // Modify the image url. 145 var img_title = $(child).attr("title"); 146 if (!img_title) { 147 img_title = $(this).attr("title"); 148 if (!img_title) { 149 img_title = $(child).attr("alt"); 150 } 151 $(child).attr({title: img_title}); 152 } 153 if (lightframe) { 154 href = frame_href; 155 } 156 if (!custom_class) { 157 var title_link = ""; 158 if (link_text.length) { 159 title_link = "<br /><br /><a href=\"" + orig_href + "\" id=\"node_link_text\" "+ link_target +" >"+ link_text + "</a>"; 160 } 161 if (download_link_text.length) { 162 title_link = title_link + " - <a href=\"" + download + "\" id=\"download_link_text\" target=\"_blank\">" + download_link_text + "</a>"; 163 } 164 rel = rel + "[" + alt + title_link + "]"; 165 $(this).attr({ 166 rel: rel, 167 href: href 168 }); 169 } 170 else { 171 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 172 rel = rel_type + "[" + $(child).attr("class") + "]"; 173 if ($(child).parents("div.block-image").attr("class")) { 174 id = $(child).parents("div.block-image").attr("id"); 175 rel = rel_type + "["+ id +"]"; 176 } 177 } 178 rel = rel + "[" + alt + "]"; 179 $(this).attr({ 180 rel: rel, 181 href: orig_href 182 }); 183 } 184 } 185 } 186 187 }); 188} 189 190function lightbox2_init_acidfree_video() { 191 var settings = Drupal.settings.lightbox2; 192 193 var link_target = ""; 194 if (settings.node_link_target !== 0) { 195 link_target = 'target="'+ settings.node_link_target +'"'; 196 } 197 198 var link_text = settings.node_link_text; 199 var rel = "lightframe"; 200 201 $("div.acidfree-video a").each(function(i) { 202 203 if (!settings.disable_for_acidfree_gallery_lists || (!$(this).parents(".acidfree-folder").length && !$(this).parents(".acidfree-list").length) || (($(this).parents(".acidfree-folder").length || $(this).parents(".acidfree-list").length) && !sett
203ings.disable_for_acidfree_gallery_lists)) { 204 var orig_href = $(this).attr("href"); 205 var href = orig_href + "/lightframevideo"; 206 var title = $(this).attr("title"); 207 var title_link = ""; 208 if (link_text.length) { 209 title_link = "<br /><a href=\"" + orig_href + "\" id=\"node_link_text\" "+ link_target +" >"+ link_text + "</a>"; 210 } 211 212 $(this).attr({ 213 rel: rel, 214 title: title + title_link, 215 href: href 216 }); 217 } 218 }); 219} 220 221function lightbox2_image_nodes() { 222 223 var settings = Drupal.settings.lightbox2; 224 225 // Don't do it on the image assist popup selection screen. 226 var img_assist = document.getElementById("img_assist_thumbs"); 227 if (!img_assist) { 228 229 // Select the enabled image types. 230 lightbox2_init_triggers(settings.trigger_lightbox_classes, "lightbox_ungrouped"); 231 lightbox2_init_triggers(settings.custom_trigger_classes, settings.custom_class_handler, true); 232 lightbox2_init_triggers(settings.trigger_lightbox_group_classes, "lightbox"); 233 lightbox2_init_triggers(settings.trigger_slideshow_classes, "lightshow"); 234 lightbox2_init_triggers(settings.trigger_lightframe_classes, "lightframe_ungrouped"); 235 lightbox2_init_triggers(settings.trigger_lightframe_group_classes, "lightframe"); 236 if (settings.enable_acidfree_videos) { 237 lightbox2_init_acidfree_video(); 238 } 239 240 } 241} 242 243 244Drupal.behaviors.initAutoLightbox = function (context) { 245 lightbox2_image_nodes(); 246}; 247
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.