LightboxGallery.php
changeset 4 c2458c3b0365
parent 3 b52509cf73af
child 5 dd7c762112b2
equal deleted inserted replaced
3:b52509cf73af 4:c2458c3b0365
    32 
    32 
    33 function lbgallery_add_headers()
    33 function lbgallery_add_headers()
    34 {
    34 {
    35   global $db, $session, $paths, $template, $plugins; // Common objects
    35   global $db, $session, $paths, $template, $plugins; // Common objects
    36   
    36   
    37   $template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/jquery.js"></script>');
    37   if ( method_exists($template, 'preload_js') && method_exists($template, 'add_header_js') )
    38   $template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/jquery-ui.js"></script>');
    38   {
    39   $template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/lightboxgallery/jquery.lightbox-0.5.pack.js"></script>');
    39     $template->preload_js(array('jquery', 'jquery-ui'));
       
    40     $template->add_header_js('<script type="text/javascript" src="' . scriptPath . '/plugins/lightboxgallery/jquery.lightbox-0.5.pack.js"></script>');
       
    41   }
       
    42   else
       
    43   {
       
    44     $template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/jquery.js"></script>');
       
    45     $template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/jquery-ui.js"></script>');
       
    46     $template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/lightboxgallery/jquery.lightbox-0.5.pack.js"></script>');
       
    47   }
    40   $template->add_header('<link rel="stylesheet" type="text/css" href="' . scriptPath . '/plugins/lightboxgallery/jquery.lightbox-0.5.css" />');
    48   $template->add_header('<link rel="stylesheet" type="text/css" href="' . scriptPath . '/plugins/lightboxgallery/jquery.lightbox-0.5.css" />');
    41   $template->add_header('<script type="text/javascript">
    49   $template->add_header('<script type="text/javascript">
    42       var loaded_components = loaded_components || {};
    50       var loaded_components = loaded_components || {};
    43       loaded_components["jquery.js"] = true;
    51       loaded_components["jquery.js"] = true;
    44       loaded_components["jquery-ui.js"] = true;
    52       loaded_components["jquery-ui.js"] = true;
    99     else
   107     else
   100     {
   108     {
   101       $alt = str_replace('_', ' ', dirtify_page_id($image));
   109       $alt = str_replace('_', ' ', dirtify_page_id($image));
   102     }
   110     }
   103     $imagelist[] = array($image, $alt);
   111     $imagelist[] = array($image, $alt);
   104     $tag = '<a class="' . $id . '" href="' . makeUrlNS('Special', "DownloadFile/$image", "preview&width=$width&height=9999", true) . '" title="' . trim(htmlspecialchars(RenderMan::render($alt))) . '">';
   112     $tag = '<a class="' . $id . '" href="' . makeUrlNS('Special', "DownloadFile/$image", "preview&width=$width&height=9999&fmt=jpg", true) . '" title="' . trim(htmlspecialchars(RenderMan::render($alt))) . '">';
   105     if ( !isset($firstimageid) )
   113     if ( !isset($firstimageid) )
   106     {
   114     {
   107       $firstimagetag = $tag;
   115       $firstimagetag = $tag;
   108       $firstimageid = $image;
   116       $firstimageid = $image;
   109       $firstimagealt = $alt;
   117       $firstimagealt = $alt;
   130   $trigger = str_replace(array('<randomimage>', '<randomimage/>', '<randomimage />'), $randomimage, $trigger);
   138   $trigger = str_replace(array('<randomimage>', '<randomimage/>', '<randomimage />'), $randomimage, $trigger);
   131   
   139   
   132   return "$trigger<nowiki>
   140   return "$trigger<nowiki>
   133     <div style=\"display: none;\">$inner</div>
   141     <div style=\"display: none;\">$inner</div>
   134     <script type=\"text/javascript\">
   142     <script type=\"text/javascript\">
   135       addOnloadHook(function()
   143       window.lbg_construct_$id = function()
   136         {
   144         {
   137           lbgallery_construct('a.$id');
   145           if ( window.jQuery && window.jQuery.fn.lightBox )
   138         });
   146           {
       
   147             lbgallery_construct('a.$id');
       
   148           }
       
   149           else
       
   150           {
       
   151             setTimeout(lbg_construct_$id, 200);
       
   152           }
       
   153         };
       
   154       addOnloadHook(window.lbg_construct_$id);
   139     </script></nowiki>";
   155     </script></nowiki>";
   140 }
   156 }
   141 
   157 
   142 /**!language**
   158 /**!language**
   143 
   159