Browse Source

Do lightbox init in global.js instead of onclicks

spaghetti 8 years ago
parent
commit
fef2fb5797

+ 1
- 1
classes/imagetools.class.php View File

@@ -243,7 +243,7 @@ class ImageTools {
243 243
       $Lightbox = $Src;
244 244
     }
245 245
 ?>
246
-    <img src="<?=$Src?>" width="90" height="90" alt="Cover" onclick="lightbox.init('<?=$Lightbox?>', 90)" />
246
+    <img src="<?=$Src?>" width="90" height="90" alt="Cover" class="lightbox-init" lightbox-img="<?=$Lightbox?>" />
247 247
 <?
248 248
   }
249 249
 }

+ 2
- 2
classes/text.class.php View File

@@ -863,9 +863,9 @@ class Text {
863 863
           } else {
864 864
             $LocalURL = self::local_url($Block['Val']);
865 865
             if ($LocalURL) {
866
-              $Str .= '<img class="scale_image" onclick="lightbox.init(this, $(this).width());" alt="'.$Block['Val'].'" src="'.$LocalURL.'" />';
866
+              $Str .= '<img class="scale_image lightbox-init" alt="'.$Block['Val'].'" src="'.$LocalURL.'" />';
867 867
             } else {
868
-              $Str .= '<img class="scale_image" onclick="lightbox.init(this, $(this).width());" alt="'.$Block['Val'].'" src="'.ImageTools::process($Block['Val']).'" />';
868
+              $Str .= '<img class="scale_image lightbox-init" alt="'.$Block['Val'].'" src="'.ImageTools::process($Block['Val']).'" />';
869 869
             }
870 870
           }
871 871
           break;

+ 1
- 1
sections/artist/artist.php View File

@@ -455,7 +455,7 @@ if (check_perms('site_torrents_notify')) {
455 455
     <div class="box box_image">
456 456
       <div class="head"><strong><?=$Name?></strong></div>
457 457
       <div style="text-align: center; padding: 10px 0px;">
458
-        <img style="max-width: 220px;" src="<?=ImageTools::process($Image, true)?>" alt="<?=$Name?>" onclick="lightbox.init('<?=ImageTools::process($Image)?>', 220);" />
458
+        <img style="max-width: 220px;" class="lightbox-init" src="<?=ImageTools::process($Image, true)?>" alt="<?=$Name?>" />
459 459
       </div>
460 460
     </div>
461 461
 <?  } ?>

+ 1
- 1
sections/reportsv2/ajax_new_report.php View File

@@ -313,7 +313,7 @@ $DB->query("
313 313
         $Images = explode(' ', $Images);
314 314
         foreach ($Images as $Image) {
315 315
     ?>
316
-              <img style="max-width: 200px;" onclick="lightbox.init(this, 200);" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
316
+              <img style="max-width: 200px;" class="lightbox-init" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
317 317
 <?
318 318
         } ?>
319 319
             </td>

+ 1
- 1
sections/reportsv2/static.php View File

@@ -573,7 +573,7 @@ if (count($Reports) === 0) {
573 573
         $Images = explode(' ', $Images);
574 574
         foreach ($Images as $Image) {
575 575
 ?>
576
-            <img style="max-width: 200px;" onclick="lightbox.init(this, 200);" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
576
+            <img style="max-width: 200px;" class="lightbox-init" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
577 577
 <?        } ?>
578 578
           </td>
579 579
         </tr>

+ 1
- 1
sections/requests/request.php View File

@@ -118,7 +118,7 @@ $encoded_artist = urlencode($encoded_artist);
118 118
 <?
119 119
     if (!empty($Request['Image'])) {
120 120
 ?>
121
-          <p align="center"><img style="width: 100%;" src="<?=ImageTools::process($Request['Image'], true)?>" alt="<?=$FullName?>" onclick="lightbox.init('<?=ImageTools::process($Request['Image'])?>', 220);" /></p>
121
+          <p align="center"><img style="width: 100%;" src="<?=ImageTools::process($Request['Image'], true)?>" alt="<?=$FullName?>" class="lightbox-init" /></p>
122 122
 <?    } else { ?>
123 123
           <p align="center"><img style="width: 100%;" src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$Request['CategoryID'] - 1]?>" alt="<?=$CategoryName?>" class="tooltip" title="<?=$CategoryName?>" height="220" border="0" /></p>
124 124
 <?    } ?>

+ 3
- 3
sections/torrents/details.php View File

@@ -192,7 +192,7 @@ View::show_header($Title, 'browse,comments,torrent,bbcode,recommend,cover_art,su
192 192
 <div id="covers">
193 193
 <div id="cover_div_<?=$Index?>">
194 194
 <?  if ($WikiImage != '') { ?>
195
-      <div><img width="100%" src="<?=ImageTools::process($WikiImage, true)?>" alt="<?=$AltName?>" onclick="lightbox.init('<?=ImageTools::process($WikiImage)?>', 245);" /></div>
195
+      <div><img width="100%" class="lightbox-init" src="<?=ImageTools::process($WikiImage, true)?>" alt="<?=$AltName?>" /></div>
196 196
 <?  } else { ?>
197 197
       <div><img width="100%" src="<?=STATIC_SERVER?>common/noartwork/comedy.png<? /*=$CategoryIcons[$GroupCategoryID - 1]*/ ?>" alt="<?=$Categories[$GroupCategoryID - 1]?>" class="brackets tooltip" title="<?=$Categories[$GroupCategoryID - 1]?>" height="220" border="0" /></div>
198 198
 <?
@@ -212,7 +212,7 @@ $Index++;
212 212
             $Src = 'src="' . ImageTools::process($Image, true) . '"';
213 213
           }
214 214
 ?>
215
-          <img id="cover_<?=$Index?>" width="100%" <?=$Src?> alt="<?=$Summary?>" onclick="lightbox.init('<?=ImageTools::process($Image)?>', 220);" />
215
+          <img id="cover_<?=$Index?>" class="lightbox-init" lightbox-img="<?=ImageTools::process($Image)?>" width="100%" <?=$Src?> alt="<?=$Summary?>" />
216 216
         </div>
217 217
         <ul class="stats nobullet">
218 218
           <li>
@@ -788,7 +788,7 @@ include(SERVER_ROOT.'/sections/torrents/voter_picks.php');
788 788
 <?
789 789
     foreach($Screenshots as $Screenshot) {
790 790
       $SSURL = ImageTools::process($Screenshot['Image'], false)
791
-      ?><img class='tooltip' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' onclick="lightbox.init('<?=$SSURL?>', 220);" src="<?=$SSURL?>" /><?
791
+      ?><img class='tooltip lightbox-init' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' src="<?=$SSURL?>" /><?
792 792
     }
793 793
 ?>
794 794
       </div>

+ 1
- 1
sections/torrents/editgroup.php View File

@@ -161,7 +161,7 @@ View::show_header('Edit torrent group', 'upload');
161 161
               <a onclick="RemoveScreenshotField(this)" class="brackets">&minus;</a>
162 162
 <? } ?>
163 163
               <br />
164
-              <img class="tooltip" title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' style="width: 30%;" onclick="lightbox.init('<?=$SSURL?>', 220);" src="<?=$SSURL?>" />
164
+              <img class="tooltip lightbox-init" title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' style="width: 30%;" src="<?=$SSURL?>" />
165 165
             </div>
166 166
             <br />
167 167
 <? } ?>

+ 6
- 0
static/functions/global.js View File

@@ -219,4 +219,10 @@ $(function() {
219 219
       }
220 220
     })
221 221
   })
222
+
223
+  document.querySelectorAll('.lightbox-init').forEach(function(el) {
224
+    el.addEventListener('click', function(event) {
225
+      lightbox.init(el.attributes['lightbox-img']||el.src, el.attributes['lightbox-size']||el.width)
226
+    })
227
+  })
222 228
 })

Loading…
Cancel
Save