1/* $Id: auto_image_handling.js,v 1.1.2.18 2008/06/27 12:30:02 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["+classes+"], 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 48 // Set the rel attribute. 49 var rel = "lightbox"; 50 var lightframe = false; 51 if (rel_type == "lightframe_ungrouped") { 52 rel = "lightframe[]"; 53 lightframe = true; 54 } 55 else if (rel_type == "lightframe") { 56 lightframe = true; 57 } 58 else if (rel_type == "lightbox_ungrouped") { 59 lightframe = "lightbox[]"; 60 } 61 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 62 rel = rel_type + "[" + $(child).attr("class") + "]"; 63 } 64 65 // Set the basic href attribute - need to ensure there's no language 66 // string (e.g. /en) prepended to the URL. 67 var id = null; 68 var href = $(child).attr("src"); 69 var orig_href = $(this).attr("href"); 70 var pattern = new RegExp(settings.file_path); 71 if (orig_href.match(pattern)) { 72 var lang_pattern = new RegExp(settings.base_path + "\\w\\w\\/"); 73 orig_href = orig_href.replace(lang_pattern, settings.base_path); 74 } 75 var frame_href = orig_href; 76 77 // Handle flickr images. 78 if ($(child).attr("class").match("flickr-photo-img") || 79 $(child).attr("class").match("flickr-photoset-img")) { 80 href = $(child).attr("src").replace("_s", "").replace("_t", "").replace("_m", "").replace("_b", ""); 81 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 82 rel = rel_type + "[flickr]"; 83 if ($(child).parents("div.block-flickr").attr("class")) { 84 id = $(child).parents("div.block-flickr").attr("id"); 85 rel = rel_type + "["+ id +"]"; 86 } 87 } 88 } 89 90 // Handle "image-img_assist_custom" images. 91 else if ($(child).attr("class").match("image-img_assist_custom")) { 92 // Image assist uses "+" signs for spaces which doesn't work for 93 // normal links. 94 orig_href = orig_href.replace(/\+/, " "); 95 frame_href = orig_href; 96 href = orig_href; 97 } 98 99 // Handle "inline" images. 100 else if ($(child).attr("class").match("inline")) { 101 href = orig_href; 102 } 103 104 // Handle gallery2 block images. 105 else if ($(child).attr("class").match("ImageFrame_image") || $(child).attr("class").match("ImageFrame_none")) { 106 var thumb_id = parse_url(href, "g2_itemId"); 107 var new_id = parse_url(orig_href, "g2_itemId"); 108 if (new_id && thumb_id) { 109 var g2pattern = new RegExp("g2_itemId="+thumb_id); 110 var replacement = "g2_itemId="+ new_id; 111 href = href.replace(g2pattern, replacement); 112 } 113 rel = rel_type + "[gallery2]"; 114 if ($(child).parents("div.block-gallery").attr("class")) { 115 id = $(child).parents("div.block-gallery").attr("id"); 116 rel = rel_type + "["+ id +"]"; 117 } 118 } 119 120 121 // Set the href attribute. 122 else if (settings.image_node_sizes != '()' && !custom_class) { 123 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)); 124 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 125 rel = rel_type + "[node_images]"; 126 if ($(child).parents("div.block-multiblock,div.block-image").attr("class")) { 127 id = $(child).parents("div.block-multiblock,div.block-image").attr("id"); 128 rel = rel_type + "["+ id +"]"; 129 } 130 } 131 if (lightframe) { 132 frame_href = orig_href + "/lightbox2"; 133 } 134 } 135 136 // Modify the image url. 137 var img_title = $(child).attr("title"); 138 if (!img_title) { 139 img_title = $(this).attr("title"); 140 if (!img_title) { 141 img_title = $(child).attr("alt"); 142 } 143 $(child).attr({title: img_title}); 144 } 145 if (lightframe) { 146 href = frame_href; 147 } 148 if (!custom_class) { 149 var title_link = ""; 150 if (link_text.length) { 151 title_link = "<br /><a href=\"" + orig_href + "\" id=\"node_link_text\" "+ link_target +" >"+ link_text + "</a>"; 152 } 153 rel = rel + "[" + alt + title_link + "]"; 154 $(this).attr({ 155 rel: rel, 156 href: href 157 }); 158 } 159 else { 160 if (rel_type != "lightbox_ungrouped" && rel_type != "lightframe_ungrouped") { 161 rel = rel_type + "[" + $(child).attr("class") + "]"; 162 if ($(child).parents("div.block-image").attr("class")) { 163 id = $(child).parents("div.block-image").attr("id"); 164 rel = rel_type + "["+ id +"]"; 165 } 166 } 167 rel = rel + "[" + alt + "]"; 168 $(this).attr({ 169 rel: rel, 170 href: orig_href 171 }); 172 } 173 } 174 } 175 176 }); 177 178} 179 180function lightbox2_init_acidfree_video() { 181 var settings = Drupal.settings.lightbox2; 182 183 var link_target = ""; 184 if (settings.node_link_target !== 0) { 185 link_target = 'target="'+ settings.node_link_target +'"'; 186 } 187 188 var link_text = settings.node_link_text; 189 var rel = "lightframe"; 190 191 $("div.acidfree-video a").each(function(i) { 192 193 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
193ings.disable_for_acidfree_gallery_lists)) { 194 var orig_href = $(this).attr("href"); 195 var href = orig_href + "/lightframevideo"; 196 var title = $(this).attr("title"); 197 var title_link = ""; 198 if (link_text.length) { 199 title_link = "<br /><a href=\"" + orig_href + "\" id=\"node_link_text\" "+ link_target +" >"+ link_text + "</a>"; 200 } 201 202 $(this).attr({ 203 rel: rel, 204 title: title + title_link, 205 href: href 206 }); 207 } 208 }); 209} 210 211if (Drupal.jsEnabled) { 212 $(document).ready(function lightbox2_image_nodes() { 213 214 var settings = Drupal.settings.lightbox2; 215 216 // Don't do it on the image assist popup selection screen. 217 var img_assist = document.getElementById("img_assist_thumbs"); 218 if (!img_assist) { 219 220 // Select the enabled image types. 221 lightbox2_init_triggers(settings.trigger_lightbox_classes, "lightbox_ungrouped"); 222 lightbox2_init_triggers(settings.custom_trigger_classes, settings.custom_class_handler, true); 223 lightbox2_init_triggers(settings.trigger_lightbox_group_classes, "lightbox"); 224 lightbox2_init_triggers(settings.trigger_slideshow_classes, "lightshow"); 225 lightbox2_init_triggers(settings.trigger_lightframe_classes, "lightframe_ungrouped"); 226 lightbox2_init_triggers(settings.trigger_lightframe_group_classes, "lightframe"); 227 if (settings.enable_acidfree_videos) { 228 lightbox2_init_acidfree_video(); 229 } 230 231 } 232 }); 233}
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.