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
       $Lightbox = $Src;
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
           } else {
863
           } else {
864
             $LocalURL = self::local_url($Block['Val']);
864
             $LocalURL = self::local_url($Block['Val']);
865
             if ($LocalURL) {
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
             } else {
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
           break;
871
           break;

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

455
     <div class="box box_image">
455
     <div class="box box_image">
456
       <div class="head"><strong><?=$Name?></strong></div>
456
       <div class="head"><strong><?=$Name?></strong></div>
457
       <div style="text-align: center; padding: 10px 0px;">
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
       </div>
459
       </div>
460
     </div>
460
     </div>
461
 <?  } ?>
461
 <?  } ?>

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

313
         $Images = explode(' ', $Images);
313
         $Images = explode(' ', $Images);
314
         foreach ($Images as $Image) {
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
             </td>
319
             </td>

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

573
         $Images = explode(' ', $Images);
573
         $Images = explode(' ', $Images);
574
         foreach ($Images as $Image) {
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
           </td>
578
           </td>
579
         </tr>
579
         </tr>

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

118
 <?
118
 <?
119
     if (!empty($Request['Image'])) {
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
 <?    } else { ?>
122
 <?    } else { ?>
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>
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
 <div id="covers">
192
 <div id="covers">
193
 <div id="cover_div_<?=$Index?>">
193
 <div id="cover_div_<?=$Index?>">
194
 <?  if ($WikiImage != '') { ?>
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
 <?  } else { ?>
196
 <?  } else { ?>
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>
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
             $Src = 'src="' . ImageTools::process($Image, true) . '"';
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
         </div>
216
         </div>
217
         <ul class="stats nobullet">
217
         <ul class="stats nobullet">
218
           <li>
218
           <li>
788
 <?
788
 <?
789
     foreach($Screenshots as $Screenshot) {
789
     foreach($Screenshots as $Screenshot) {
790
       $SSURL = ImageTools::process($Screenshot['Image'], false)
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
       </div>
794
       </div>

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

161
               <a onclick="RemoveScreenshotField(this)" class="brackets">&minus;</a>
161
               <a onclick="RemoveScreenshotField(this)" class="brackets">&minus;</a>
162
 <? } ?>
162
 <? } ?>
163
               <br />
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
             </div>
165
             </div>
166
             <br />
166
             <br />
167
 <? } ?>
167
 <? } ?>

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

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