PageSourceSearch

https://www.brcixopo.co.za/media/joomgallery/js/thickbox3/js/thickbox.js

js brcixopo.co.za collected 2026-10-09 00:29:22 UTC 17,488 bytes, 629 lines download raw bytes

1/*
2 * Thickbox 3 - One Box To Rule Them All.
3 * By Cody Lindley (http://www.codylindley.com)
4 * Copyright (c) 2007 cody lindley
5 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
6 */
7
8/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
9jQuery.noConflict();
10
11// for saving the onkey event from JoomGallery
12var joom_onkeydownsave;
13
14// on page load call tb_init
15jQuery(document).ready(function()
16{
17  // modify all thickbox links having a rel tag 'thickbox.<group>'
18  var sstr    = 'thickbox';
19
20  jQuery("a[rel^=" + sstr + "]").each(function(){
21    jQuery(this).addClass(sstr);
22    this.rel = this.rel.substr(9);
23  });
24
25  // save the initial state of onkey event
26  joom_onkeydownsave = document.onkeydown;
27  tb_init('a.thickbox, area.thickbox, input.thickbox');// pass where to apply
28  // thickbox
29  imgLoader = new Image();// preload image
30  imgLoader.src = tb_pathToImage;
31});
32
33// add thickbox to href & area elements that have a class of .thickbox
34function tb_init(domChunk)
35{
36  jQuery(domChunk).click(function()
37  {
38    var t = this.title || this.name || null;
39    var a = this.href || this.alt;
40    var g = this.rel || false;
41    tb_show(t, a, g);
42    this.blur();
43    return false;
44  });
45}
46
47// Internal functions for JoomGallery
48// needful to avoid displaying the same picture multiple
49// and the right counter in the slimbox
50// JoomGallery team April 2010
51
52// Analyze the images array and construct
53// an array with unique numbers
54function joomcheckmulti(images)
55{
56  var o =
57  {};
58  for ( var i = 0; i < images.length; i++)
59  {
60    // Create an array with unique URL
61    // and number of object in images
62    o[images[i].href] = i;
63  }
64  // Create an array with the object numbers from o
65  var p = new Array();
66  for ( var i in o)
67  {
68    p[o[i]] = true;
69  }
70  return p;
71}
72
73// Returns the count of all unique pictures
74function joomuniquelength (uniarr)
75{
76  var arrlength=uniarr.length;
77  var uniquelength=arrlength;
78
79  for (var i=0; i<arrlength; i++)
80  {
81    if(uniarr[i] != true)
82    {
83      uniquelength--;
84    }
85  }
86  return uniquelength;
87}
88
89// Returns the max. object id of picture in the array
90function joomidmax(uniarr, imlength)
91{
92  var maxid = 0;
93  for ( var i = 0; i <= imlength; i++)
94  {
95    if (uniarr[i] == true)
96    {
97      maxid = Math.max(maxid, i);
98    }
99  }
100  return maxid;
101}
102
103// Returns the count of actual picture showing in the box
104function joomgetactcount(uniarr, imlength, aktcounter)
105{
106  var actcount = 0;
107  for ( var i = 0; i <= imlength; i++)
108  {
109    if (uniarr[i] == true)
110    {
111      actcount++;
112      if (i == aktcounter)
113      {
114        break;
115      }
116    }
117  }
118  return actcount;
119}
120// end internal functions for JoomGallery
121
122function tb_show(caption, url, imageGroup)
123{// function called when the user clicks on a thickbox link
124  try
125  {
126    if (typeof document.body.style.maxHeight === "undefined")
127    {// if IE 6
128      jQuery("body", "html").css(
129      {
130        height : "100%",
131        width : "100%"
132      });
133      jQuery("html").css("overflow", "hidden");
134      if (document.getElementById("TB_HideSelect") === null)
135      {// iframe to hide select elements in ie6
136        jQuery("body")
137            .append(
138                "<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
139        jQuery("#TB_overlay").click(tb_remove);
140      }
141    }
142    else
143    {// all others
144      if (document.getElementById("TB_overlay") === null)
145      {
146        jQuery("body")
147            .append("<div id='TB_overlay'></div><div id='TB_window'>");
148        jQuery("#TB_overlay").click(tb_remove);
149      }
150    }
151
152    if (caption === null)
153    {
154      caption = "";
155    }
156    jQuery("body").append(
157        "<div id='TB_load'><img src='" + imgLoader.src + "' /></div>");// add
158    // loader
159    // to
160    // the
161    // page
162    jQuery('#TB_load').show();// show loader
163
164    var baseURL;
165    if (url.indexOf("?") !== -1)
166    { // ff there is a query string involved
167      baseURL = url.substr(0, url.indexOf("?"));
168    }
169    else
170    {
171      baseURL = url;
172    }
173
174    var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.bmp/g;
175    var urlType = baseURL.toLowerCase().match(urlString);
176
177    if (true)
178    { // (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' ||
179      // urlType == '.gif' || urlType == '.bmp'){//code to show images
180
181      TB_PrevCaption = "";
182      TB_PrevURL = "";
183      TB_PrevHTML = "";
184      TB_NextCaption = "";
185      TB_NextURL = "";
186      TB_NextHTML = "";
187      TB_imageCount = "";
188      TB_FoundURL = false;
189      if (imageGroup)
190      {
191        TB_TempArray = jQuery("a[rel=" + imageGroup + "]").get();
192
193        // edit JoomGallery team
194        // check multiple links for correction of the counter
195        // return an array with unique object keys
196        var uniquearr = new Array();
197        uniquearr = joomcheckmulti(TB_TempArray);
198        var uniquecount = joomuniquelength(uniquearr);
199        var uniquemaxid = joomidmax(uniquearr, TB_TempArray.length);
200
201        for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++)
202        {
203          if ((TB_TempArray[TB_Counter].href == url))
204          {
205            // actual picture found
206            var prevImage = TB_Counter - 1;
207            var nextImage = TB_Counter + 1;
208            var changed = false;
209            while (uniquearr[TB_Counter] != true)
210            {
211              TB_Counter++;
212              changed = true;
213            }
214            if (changed)
215            {
216              prevImage = TB_Counter - 1;
217              nextImage = TB_Counter + 1;
218            }
219            // look for previous and next image
220            while (uniquearr[prevImage] != true && prevImage >= 0)
221            {
222              prevImage--;
223            }
224            while (uniquearr[nextImage] != true && nextImage <= uniquemaxid)
225            {
226              nextImage++;
227            }
228            if (nextImage > uniquemaxid)
229            {
230              nextImage = -1;
231            }
232            // get the right counter of actual image
233            var imageactcounter = 0;
234            if (prevImage < 0)
235            {
236              imageactcounter = 1;
237            }
238            else
239            {
240              imageactcounter = joomgetactcount(uniquearr, TB_TempArray.length,
241                  TB_Counter);
242            }
243            // actual image
244            TB_imageCount = joomgallery_image + " " + (imageactcounter) + " "
245                + joomgallery_of + " " + (uniquecount);
246
247            // next image if existent
248            if (nextImage != -1)
249            {
250              TB_NextCaption = TB_TempArray[nextImage].title;
251              TB_NextURL = TB_TempArray[nextImage].href;
252              // Edit b2m language
253              TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>"
254                  + joomgallery_next + " &gt;</a></span>";
255            }
256            // previous picture if existent
257            if (prevImage >= 0)
258            {
259              TB_PrevCaption = TB_TempArray[prevImage].title;
260              TB_PrevURL = TB_TempArray[prevImage].href;
261              // Edit b2m language
262              TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt;"
263                  + joomgallery_prev + "</a></span>";
264            }
265            break;
266          }
267        }
268      }
269
270      imgPreloader = new Image();
271      imgPreloader.onload = function()
272      {
273        imgPreloader.onload = null;
274
275        // Resizing large images - orginal by Christian Montoya edited by me.
276        var pagesize = tb_getPageSize();
277        var x = pagesize[0] - 150;
278        var y = pagesize[1] - 150;
279        var imageWidth = imgPreloader.width;
280        var imageHeight = imgPreloader.height;
281        // Edit b2m edit resize
282        if (resizeJsImage == 1)
283        {
284          if (imageWidth > x)
285          {
286            imageHeight = imageHeight * (x / imageWidth);
287            imageWidth = x;
288          }
289          if (imageHeight > y)
290          {
291            imageWidth = imageWidth * (y / imageHeight);
292            imageHeight = y;
293          }
294        }
295        // End b2m Edit resize
296        // End Resizing
297
298        TB_WIDTH = imageWidth + 30;
299        TB_HEIGHT = imageHeight + 60;
300        // Edit b2m language
301        jQuery("#TB_window")
302            .append(
303                "<a href='' id='TB_ImageOff' title='"
304                    + joomgallery_close
305                    + "'><img id='TB_Image' src='"
306                    + url
307                    + "' width='"
308                    + imageWidth
309                    + "' height='"
310                    + imageHeight
311                    + "'/></a>"
312                    + "<div id='TB_caption'>"
313                    + caption
314                    + "<div id='TB_secondLine'>"
315                    + TB_imageCount
316                    + TB_PrevHTML
317                    + TB_NextHTML
318                    + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='"
319                    + joomgallery_close + "'>" + joomgallery_close + "</a> "
320                    + joomgallery_press_esc + "</div>");
321        // End edit b2m language
322
323        jQuery("#TB_closeWindowButton").click(tb_remove);
324
325        if (!(TB_PrevHTML === ""))
326        {
327          function goPrev()
328          {
329            if (jQuery(document).unbind("click", goPrev))
330            {
331              jQuery(document).unbind("click", goPrev);
332            }
333            jQuery("#TB_window").remove();
334            jQuery("body").append("<div id='TB_window'></div>");
335            tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
336            return false;
337          }
338          jQuery("#TB_prev").click(goPrev);
339        }
340
341        if (!(TB_NextHTML === ""))
342        {
343          function goNext()
344          {
345            jQuery("#TB_window").remove();
346            jQuery("body").append("<div id='TB_window'></div>");
347            tb_show(TB_NextCaption, TB_NextURL, imageGroup);
348            return false;
349          }
350          jQuery("#TB_next").click(goNext);
351
352        }
353
354        document.onkeydown = function(e)
355        {
356          if (e == null)
357          { // ie
358            keycode = event.keyCode;
359          }
360          else
361          { // mozilla
362            keycode = e.which;
363          }
364
365          keychar = String.fromCharCode(keycode).toLowerCase();
366
367          if (keycode == 27)
368          { // close
369            tb_remove();
370          }
371          else if (keychar == 'n' || keycode == 39)
372          { // display next image
373            if (!(TB_NextHTML == ""))
374            {
375              document.onkeydown = "";
376              goNext();
377            }
378          }
379          else if (keychar == 'p' || keycode == 37)
380          { // display previous image
381            if (!(TB_PrevHTML == ""))
382            {
383              document.onkeydown = "";
384              goPrev();
385            }
386          }
387        };
388
389        tb_position();
390        jQuery("#TB_load").remove();
391        jQuery("#TB_ImageOff").click(tb_remove);
392        jQuery("#TB_window").css(
393        {
394          display : "block"
395        }); // for safari using css instead of show
396      };
397
398      imgPreloader.src = url;
399    }
400    else
401    {// code to show html pages
402
403      var queryString = url.replace(/^[^\?]+\??/, '');
404      var params = tb_parseQuery(queryString);
405
406      TB_WIDTH = (params['width'] * 1) + 30 || 630; // defaults to 630 if no
407      // paramaters were added to
408      // URL
409      TB_HEIGHT = (params['height'] * 1) + 40 || 440; // defaults to 440 if no
410      // paramaters were added
411      // to URL
412      ajaxContentW = TB_WIDTH - 30;
413      ajaxContentH = TB_HEIGHT - 45;
414
415      if (url.indexOf('TB_iframe') != -1)
416      {
417        urlNoQuery = url.split('TB_');
418        // Edit b2m language
419        jQuery("#TB_window")
420            .append(
421                "<div id='TB_title'><div id='TB_ajaxWindowTitle'>"
422                    + caption
423                    + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='"
424                    + joomgallery_close
425                    + "'>"
426                    + joomgallery_close
427                    + "</a> "
428                    + joomgallery_press_esc
429                    + "</div></div><iframe frameborder='0' hspace='0' src='"
430                    + urlNoQuery[0]
431                    + "' id='TB_iframeContent' name='TB_iframeContent' style='width:"
432                    + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17)
433                    + "px;' onload='tb_showIframe()'> </iframe>");
434      }
435      else
436      {
437        if (jQuery("#TB_window").css("display") != "block")
438        {
439          if (params['modal'] != "true")
440          {
441            jQuery("#TB_window")
442                .append(
443                    "<div id='TB_title'><div id='TB_ajaxWindowTitle'>"
444                        + caption
445                        + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>"
446                        + joomgallery_close + "</a> " + joomgallery_press_esc
447                        + "</div></div><div id='TB_ajaxContent' style='width:"
448                        + ajaxContentW + "px;height:" + ajaxContentH
449                        + "px'></div>");
450            // End Edit b2m language
451          }
452          else
453          {
454            jQuery("#TB_overlay").unbind();
455            jQuery("#TB_window").append(
456                "<div id='TB_ajaxContent' class='TB_modal' style='width:"
457                    + ajaxContentW + "px;height:" + ajaxContentH
458                    + "px;'></div>");
459          }
460        }
461        else
462        {
463          jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW + "px";
464          jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH + "px";
465          jQuery("#TB_ajaxContent")[0].scrollTop = 0;
466          jQuery("#TB_ajaxWindowTitle").html(caption);
467        }
468      }
469
470      jQuery("#TB_closeWindowButton").click(tb_remove);
471
472      if (url.indexOf('TB_inline') != -1)
473      {
474        jQuery("#TB_ajaxContent").html(jQuery('#' + params['inlineId']).html());
475        tb_position();
476        jQuery("#TB_load").remove();
477        jQuery("#TB_window").css(
478        {
479          display : "block"
480        });
481      }
482      else if (url.indexOf('TB_iframe') != -1)
483      {
484        tb_position();
485        if (frames['TB_iframeContent'] === undefined)
486        {// be nice to safari
487          jQuery("#TB_load").remove();
488          jQuery("#TB_window").css(
489          {
490            display : "block"
491          });
492          jQuery(document).keyup(function(e)
493          {
494            var key = e.keyCode;
495            if (key == 27)
496            {
497              tb_remove();
498            }
499          });
500        }
501      }
502      else
503      {
504        jQuery("#TB_ajaxContent").load(
505            url += "&random=" + (new Date().getTime()), function()
506            {// to do a post change this load method
507              tb_position();
508              jQuery("#TB_load").remove();
509              tb_init("#TB_ajaxContent a.thickbox");
510              jQuery("#TB_window").css(
511              {
512                display : "block"
513              });
514            });
515      }
516
517    }
518
519    if (!params['modal'])
520    {
521      document.onkeyup = function(e)
522      {
523        if (e == null)
524        { // ie
525          keycode = event.keyCode;
526        }
527        else
528        { // mozilla
529          keycode = e.which;
530        }
531        if (keycode == 27)
532        { // close
533          tb_remove();
534        }
535      };
536    }
537
538  } catch (e)
539  {
540    // nothing here
541  }
542}
543
544// helper functions below
545function tb_showIframe()
546{
547  jQuery("#TB_load").remove();
548  jQuery("#TB_window").css(
549  {
550    display : "block"
551  });
552}
553
554function tb_remove()
555{
556  jQuery("#TB_imageOff").unbind("click");
557  jQuery("#TB_overlay").unbind("click");
558  jQuery("#TB_closeWindowButton").unbind("click");
559  jQuery("#TB_window").fadeOut("fast", function()
560  {
561    jQuery('#TB_window,#TB_overlay,#TB_HideSelect').remove();
562  });
563  jQuery("#TB_load").remove();
564  if (typeof document.body.style.maxHeight == "undefined")
565  {// if IE 6
566    jQuery("body", "html").css(
567    {
568      height : "auto",
569      width : "auto"
570    });
571    jQuery("html").css("overflow", "");
572  }
573  // restore the onkeydown event from JoomGallery
574  document.onkeydown = joom_onkeydownsave;
575
576  return false;
577}
578
579function tb_position()
580{
581  jQuery("#TB_window").css(
582  {
583    marginLeft : '-' + parseInt((TB_WIDTH / 2), 10) + 'px',
584    width : TB_WIDTH + 'px'
585  });
586  if (!(jQuery.browser.msie && typeof XMLHttpRequest == 'function'))
587  { // take away IE6
588    jQuery("#TB_window").css(
589    {
590      marginTop : '-' + parseInt((TB_HEIGHT / 2), 10) + 'px'
591    });
592  }
593}
594
595function tb_parseQuery(query)
596{
597  var Params =
598  {};
599  if (!query)
600  {
601    return Params;
602  }// return empty object
603  var Pairs = query.split(/[;&]/);
604  for ( var i = 0; i < Pairs.length; i++)
605  {
606    var KeyVal = Pairs[i].split('=');
607    if (!KeyVal || KeyVal.length != 2)
608    {
609      continue;
610    }
611    var key = unescape(KeyVal[0]);
612    var val = unescape(KeyVal[1]);
613    val = val.replace(/\+/g, ' ');
614    Params[key] = val;
615  }
616  return Params;
617}
618
619function tb_getPageSize()
620{
621  var de = document.documentElement;
622  var w = window.innerWidth || self.innerWidth || (de && de.clientWidth)
623      || document.body.clientWidth;
624  var h = window.innerHeight || self.innerHeight || (de && de.clientHeight)
625      || document.body.clientHeight;
626  arrayPageSize =
627  [ w, h ];
628  return arrayPageSize;
629}

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.