Browse Source

Replace inline JS gtoggles with html attributes and some global JS

End goal is to remove all inline JS, starting with onclick
spaghetti 8 years ago
parent
commit
20aae61a7d

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

@@ -478,14 +478,14 @@ class DEBUG {
478 478
 ?>
479 479
   <table class="layout" width="100%">
480 480
     <tr>
481
-      <td align="left"><strong><a href="#" onclick="$('#debug_ocelot').gtoggle(); return false;" class="brackets">View</a> <?=number_format(count($OcelotRequests))?> Ocelot requests:</strong></td>
481
+      <td align="left"><strong><a toggle-target="#debug_ocelot" class="brackets">View</a> <?=number_format(count($OcelotRequests))?> Ocelot requests:</strong></td>
482 482
     </tr>
483 483
   </table>
484 484
   <table id="debug_ocelot" class="debug_table hidden" width="100%">
485 485
 <?    foreach ($OcelotRequests as $i => $Request) { ?>
486 486
     <tr>
487 487
       <td align="left" class="debug_data debug_ocelot_data">
488
-        <a href="#" onclick="$('#debug_ocelot_<?=$i?>').gtoggle(); return false"><?=display_str($Request['path'])?></a>
488
+        <a toggle-target="#debug_ocelot_<?=$i?>"><?=display_str($Request['path'])?></a>
489 489
         <pre id="debug_ocelot_<?=$i?>" class="hidden"><?=display_str($Request['response'])?></pre>
490 490
       </td>
491 491
       <td align="left" class="debug_info" style="width: 100px;">

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

@@ -103,7 +103,7 @@ class DonationsView {
103 103
       <div class="box">
104 104
         <div class="head">
105 105
           <span><?=!empty($ProfileRewards['ProfileInfoTitle' . $i]) ? display_str($ProfileRewards['ProfileInfoTitle' . $i]) : "Extra Profile " . ($i + 1)?></span>
106
-          <span style="float: right;"><a href="#" onclick="$('#profilediv_<?=$i?>').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Hide</a></span>
106
+          <span style="float: right;"><a toggle-target="#profilediv_<?=$i?>" toggle-replace="Show" class="brackets">Hide</a></span>
107 107
         </div>
108 108
         <div class="pad profileinfo" id="profilediv_<?=$i?>">
109 109
 <?          echo Text::full_format($ProfileRewards['ProfileInfo' . $i]); ?>
@@ -121,7 +121,7 @@ class DonationsView {
121 121
 ?>
122 122
     <div class="box box2" id="donation_history_box">
123 123
       <div class="head">
124
-        Donation History <a href="#" onclick="$('#donation_history').gtoggle(); return false;" class="brackets" style="float: right;">Toggle</a>
124
+        Donation History <a toggle-target="#donation_history" class="brackets" style="float: right;">Toggle</a>
125 125
       </div>
126 126
       <div class="hidden" id="donation_history">
127 127
         <table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">

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

@@ -56,7 +56,7 @@ class TestingView {
56 56
         <div class="head">
57 57
           <span><?=self::render_method_definition($Method)?></span>
58 58
           <span style="float: right;">
59
-            <a href="#" class="brackets" onclick="$('#method_params_<?=$Index?>').gtoggle(); return false;">Params</a>
59
+            <a toggle-target="#method_params_<?=$Index?>" class="brackets">Params</a>
60 60
             <a href="#" class="brackets run" data-gazelle-id="<?=$Index?>" data-gazelle-class="<?=$ClassName?>" data-gazelle-method="<?=$MethodName?>">Run</a>
61 61
           </span>
62 62
         </div>
@@ -172,4 +172,4 @@ class TestingView {
172 172
     echo $Results;
173 173
   }
174 174
 
175
-}
175
+}

+ 1
- 1
design/views/generic/reply/staffpm.php View File

@@ -22,6 +22,6 @@
22 22
 
23 23
         <input type="button" value="Preview" class="hidden button_preview_<?=$TextPrev->getID()?>" />
24 24
         <input type="submit" value="Send message" />
25
-        <input type="button" value="Hide" onclick="$('#compose').gtoggle(); return false;" />
25
+        <input type="button" value="Hide" toggle-target="#compose" />
26 26
       </form>
27 27
     </div>

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

@@ -630,7 +630,7 @@ if (empty($SimilarArray)) {
630 630
       <div id="info" class="head">
631 631
         <a href="#">&uarr;</a>&nbsp;
632 632
         <strong>Information</strong>
633
-        <a href="#" class="brackets" onclick="$('#body').gtoggle(); return false;">Toggle</a>
633
+        <a class="brackets" toggle-target="#body">Toggle</a>
634 634
       </div>
635 635
       <div id="body" class="body"><?=Text::full_format($Body)?></div>
636 636
     </div>
@@ -656,7 +656,7 @@ if (count($Collages) > 0) {
656 656
     $Range = range(0,count($Collages) - 1);
657 657
     shuffle($Range);
658 658
     $Indices = array_slice($Range, 0, MAX_COLLAGES);
659
-    $SeeAll = ' <a href="#" onclick="$(\'.collage_rows\').gtoggle(); return false;">(See all)</a>';
659
+    $SeeAll = ' <a toggle-target=".collage_rows">(See all)</a>';
660 660
   } else {
661 661
     $Indices = range(0, count($Collages)-1);
662 662
     $SeeAll = '';

+ 1
- 1
sections/forums/forum.php View File

@@ -87,7 +87,7 @@ View::show_header('Forums &gt; '. $Forums[$ForumID]['Name'], '', '');
87 87
 <? if (Forums::check_forumperm($ForumID, 'Write') && Forums::check_forumperm($ForumID, 'Create')) { ?>
88 88
     <a href="forums.php?action=new&amp;forumid=<?=$ForumID?>" class="brackets">New thread</a>
89 89
 <? } ?>
90
-    <a href="#" onclick="$('#searchforum').gtoggle(); this.innerHTML = (this.innerHTML == 'Search this forum' ? 'Hide search' : 'Search this forum'); return false;" class="brackets">Search this forum</a>
90
+    <a toggle-target="#searchforum" toggle-replace="Hide search" class="brackets">Search this forum</a>
91 91
     <div id="searchforum" class="hidden center">
92 92
       <div style="display: inline-block;">
93 93
         <h3>Search this forum:</h3>

+ 2
- 2
sections/forums/newthread.php View File

@@ -35,7 +35,7 @@ View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic', 'comments,bbc
35 35
     </div>
36 36
 <?  if (check_perms('forums_polls_create')) { ?>
37 37
     <div class="box thin clear hidden" id="pollpreview">
38
-      <div class="head colhead_dark"><strong>Poll</strong> <a href="#" onclick="$('#threadpoll').gtoggle(); return false;" class="brackets">View</a></div>
38
+      <div class="head colhead_dark"><strong>Poll</strong> <a toggle-target="#threadpoll" class="brackets">View</a></div>
39 39
       <div class="pad" id="threadpoll">
40 40
         <p><strong id="pollquestion"></strong></p>
41 41
         <div id="pollanswers"></div>
@@ -135,7 +135,7 @@ if (check_perms('forums_polls_create')) {
135 135
         <tr>
136 136
           <td colspan="2" class="center">
137 137
             <strong>Poll Settings</strong>
138
-            <a href="#" onclick="$('#poll_question, #poll_answers').gtoggle(); return false;" class="brackets">View</a>
138
+            <a toggle-target="#poll_question, #poll_answers" class="brackets">View</a>
139 139
           </td>
140 140
         </tr>
141 141
         <tr id="poll_question" class="hidden">

+ 1
- 1
sections/forums/search.php View File

@@ -334,7 +334,7 @@ while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body, $Threa
334 334
 <?
335 335
   }
336 336
   if ($Type == 'body') { ?>
337
-        <a href="#" onclick="$('#post_<?=$PostID?>_text').gtoggle(); return false;">(Show)</a> <span style="float: right;" class="tooltip last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if (!empty($PostID)) { echo "&amp;postid=$PostID#post$PostID"; } ?>"></a></span>
337
+        <a toggle-target="#post_<?=$PostID?>_text">(Show)</a> <span style="float: right;" class="tooltip last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if (!empty($PostID)) { echo "&amp;postid=$PostID#post$PostID"; } ?>"></a></span>
338 338
 <?  } ?>
339 339
       </td>
340 340
       <td>

+ 3
- 3
sections/forums/thread.php View File

@@ -179,7 +179,7 @@ View::show_header($ThreadInfo['Title'] . ' &lt; '.$Forums[$ForumID]['Name'].' &l
179 179
     <div class="center">
180 180
       <a href="reports.php?action=report&amp;type=thread&amp;id=<?=$ThreadID?>" class="brackets">Report thread</a>
181 181
       <a href="#" onclick="Subscribe(<?=$ThreadID?>);return false;" id="subscribelink<?=$ThreadID?>" class="brackets"><?=(in_array($ThreadID, $UserSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
182
-      <a href="#" onclick="$('#searchthread').gtoggle(); this.innerHTML = (this.innerHTML == 'Search this thread' ? 'Hide search' : 'Search this thread'); return false;" class="brackets">Search this thread</a>
182
+      <a toggle-target="#searchthread" toggle-replace="Hide search" class="brackets">Search this thread</a>
183 183
     </div>
184 184
     <div id="searchthread" class="hidden center">
185 185
       <div style="display: inline-block;">
@@ -548,7 +548,7 @@ if (check_perms('site_moderate_forums')) {
548 548
   $Notes = G::$DB->to_array();
549 549
 ?>
550 550
   <br />
551
-  <h3 id="thread_notes">Thread notes</h3> <a href="#" onclick="$('#thread_notes_table').gtoggle(); return false;" class="brackets">Toggle</a>
551
+  <h3 id="thread_notes">Thread notes</h3> <a toggle-target="#thread_notes_table" class="brackets">Toggle</a>
552 552
   <form action="forums.php" method="post">
553 553
     <input type="hidden" name="action" value="take_topic_notes" />
554 554
     <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
@@ -582,7 +582,7 @@ if (check_perms('site_moderate_forums')) {
582 582
       <tr>
583 583
         <td class="label"><label for="sticky_thread_checkbox">Sticky</label></td>
584 584
         <td>
585
-          <input type="checkbox" id="sticky_thread_checkbox" onclick="$('#ranking_row').gtoggle();" name="sticky"<? if ($ThreadInfo['IsSticky']) { echo ' checked="checked"'; } ?> tabindex="2" />
585
+          <input type="checkbox" id="sticky_thread_checkbox" toggle-target="#ranking_row" name="sticky"<? if ($ThreadInfo['IsSticky']) { echo ' checked="checked"'; } ?> tabindex="2" />
586 586
         </td>
587 587
       </tr>
588 588
       <tr id="ranking_row"<?=!$ThreadInfo['IsSticky'] ? ' class="hidden"' : ''?>>

+ 2
- 2
sections/index/private.php View File

@@ -457,7 +457,7 @@ $Cache->increment('usage_index');
457 457
   <div class="box" id="recommended">
458 458
     <div class="head colhead_dark">
459 459
       <strong>Latest Vanity House additions</strong>
460
-      <a href="#" onclick="$('#vanityhouse').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Show</a>
460
+      <a toggle-target="#vanityhouse", toggle-replace="Hide" class="brackets">Show</a>
461 461
     </div>
462 462
 
463 463
     <table class="torrent_table hidden" id="vanityhouse">
@@ -504,7 +504,7 @@ foreach ($News as $NewsItem) {
504 504
 <?  if (check_perms('admin_manage_news')) { ?>
505 505
         - <a href="tools.php?action=editnews&amp;id=<?=$NewsID?>" class="brackets">Edit</a>
506 506
 <?  } ?>
507
-      <span style="float: right;"><a href="#" onclick="$('#newsbody<?=$NewsID?>').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Hide</a></span>
507
+      <span style="float: right;"><a toggle-target="#newsbody<?=$NewsID?>" toggle-replace="Show" class="brackets">Hide</a></span>
508 508
       </div>
509 509
       <div id="newsbody<?=$NewsID?>" class="pad"><?=Text::full_format($Body)?></div>
510 510
     </div>

+ 1
- 1
sections/staff/index.php View File

@@ -18,7 +18,7 @@ list($FrontLineSupport, $ForumStaff, $Staff) = $SupportStaff;
18 18
     <h3>Contact Staff</h3>
19 19
     <div id="below_box">
20 20
       <p>If you are looking for help with a general question, we appreciate it if you would only message through the staff inbox, where we can all help you.</p>
21
-      <p>You can do that by <strong><a href="#" onclick="$('#compose').gtoggle(); return false;">sending a message to the Staff Inbox</a></strong>.</p>
21
+      <p>You can do that by <strong><a toggle-target="#compose">sending a message to the Staff Inbox</a></strong>.</p>
22 22
     </div>
23 23
     <? View::parse('generic/reply/staffpm.php', array('Hidden' => true)); ?>
24 24
 <? if ($FrontLineSupport) { ?>

+ 1
- 1
sections/staffblog/index.php View File

@@ -85,7 +85,7 @@ if (check_perms('admin_manage_blog')) {
85 85
       <div class="head">
86 86
         <?=((empty($_GET['action'])) ? 'Create a staff blog post' : 'Edit staff blog post')?>
87 87
         <span style="float: right;">
88
-          <a href="#" onclick="$('#postform').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?=(($_REQUEST['action'] != 'editblog') ? 'Show' : 'Hide')?></a>
88
+          <a toggle-target="#postform" toggle-replace="<?=(($_REQUEST['action'] != 'editblog') ? 'Hide' : 'Show')?>" class="brackets"><?=(($_REQUEST['action'] != 'editblog') ? 'Show' : 'Hide')?></a>
89 89
         </span>
90 90
       </div>
91 91
       <form class="<?=((empty($_GET['action'])) ? 'create_form' : 'edit_form')?>" name="blog_post" action="staffblog.php" method="post">

+ 1
- 1
sections/staffpm/user_inbox.php View File

@@ -24,7 +24,7 @@ $StaffPMs = $DB->query("
24 24
   <div class="header">
25 25
     <h2>Staff PMs</h2>
26 26
     <div class="linkbox">
27
-      <a href="#" onclick="$('#compose').gtoggle();" class="brackets">Compose new</a>
27
+      <a toggle-target="#compose" class="brackets">Compose new</a>
28 28
     </div>
29 29
   </div>
30 30
   <br />

+ 2
- 2
sections/staffpm/viewconv.php View File

@@ -232,7 +232,7 @@ if ($ConvID = (int)$_GET['id']) {
232 232
   if ($Status != 'Resolved') { ?>
233 233
           <input type="button" value="Resolve" onclick="location.href='staffpm.php?action=resolve&amp;id=<?=$ConvID?>';" />
234 234
 <?    if ($IsFLS) { //Moved by request ?>
235
-          <input type="button" value="Common answers" onclick="$('#common_answers').gtoggle();" />
235
+          <input type="button" value="Common answers" toggle-target="#common_answers" />
236 236
 <?    } ?>
237 237
           <input type="button" id="previewbtn" value="Preview" class="hidden button_preview_<?=$TextPrev->getID()?>" />
238 238
           <input type="submit" value="Send message" />
@@ -242,7 +242,7 @@ if ($ConvID = (int)$_GET['id']) {
242 242
   }
243 243
   if (check_perms('users_give_donor')) { ?>
244 244
           <br />
245
-          <input type="button" value="Make Donor" onclick="$('#make_donor_form').gtoggle(); return false;" />
245
+          <input type="button" value="Make Donor" toggle-target="#make_donor_form" />
246 246
 <?  } ?>
247 247
         </form>
248 248
 <?  if (check_perms('users_give_donor')) { ?>

+ 2
- 2
sections/tools/managers/enable_requests.php View File

@@ -139,8 +139,8 @@ $DB->set_query_id($QueryID);
139 139
     <a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=invalid_email&amp;<?=Format::get_url(array('view', 'action'))?>" title="Non-matching email address">Invalid Email</a>
140 140
     <a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=ip_overlap&amp;<?=Format::get_url(array('view', 'action'))?>" title="Requests with IP matches to other accounts">IP Overlap</a>
141 141
     <a class="brackets tooltip" href="tools.php?action=enable_requests&amp;view=manual_disable&amp;<?=Format::get_url(array('view', 'action'))?>" title="Requests for accounts that were not disabled for inactivity">Manual Disable</a>
142
-    <a class="brackets tooltip" href="" title="Show/Hide Search" onclick="$('#search_form').gtoggle(); return false;">Search</a>
143
-    <a class="brackets tooltip" href="" title="Show/Hide Search" onclick="$('#scores').gtoggle(); return false;">Scores</a>
142
+    <a class="brackets tooltip" title="Show/Hide Search" toggle-target="#search_form">Search</a>
143
+    <a class="brackets tooltip" title="Show/Hide Search" toggle-target="#scores">Scores</a>
144 144
 </div><br />
145 145
 <div class="thin">
146 146
     <table id="scores" class="hidden" style="width: 50%; margin: 0 auto;">

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

@@ -387,7 +387,7 @@ View::show_header('Browse Torrents', 'browse');
387 387
       <table class="layout cat_list" width="100%">
388 388
         <tr>
389 389
           <td class="label">
390
-            <a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML == 'View tags') { this.innerHTML = 'Hide tags'; } else { this.innerHTML = 'View tags'; }; return false;"><?=(empty($LoggedUser['ShowTags']) ? 'View tags' : 'Hide tags')?></a>
390
+            <a class="brackets" toggle-target="#taglist" toggle-replace="<?=(empty($LoggedUser['ShowTags']) ? 'Hide tags' : 'View tags')?>"><?=(empty($LoggedUser['ShowTags']) ? 'View tags' : 'Hide tags')?></a>
391 391
           </td>
392 392
         </tr>
393 393
       </table>

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

@@ -540,7 +540,7 @@ foreach ($TorrentList as $Torrent) {
540 540
 <?  }?>
541 541
             | <a href="torrents.php?torrentid=<?=$TorrentID ?>" class="tooltip" title="Permalink">PL</a>
542 542
           ]</span>
543
-          &raquo; <a href="#" onclick="$('#torrent_<?=$TorrentID?>').gtoggle(); return false;"><?=$ExtraInfo; ?></a>
543
+          &raquo; <a toggle-target="#torrent_<?=$TorrentID?>"><?=$ExtraInfo; ?></a>
544 544
         </td>
545 545
         <td class="number_column nobr"><?=Format::get_size($Size)?></td>
546 546
         <td class="number_column"><?=number_format($Snatched)?></td>
@@ -625,7 +625,7 @@ if (empty($LoggedUser['DisableRequests']) && count($Requests) > 0) {
625 625
     <div class="box">
626 626
       <div class="head">
627 627
         <span style="font-weight: bold;">Requests (<?=number_format(count($Requests))?>)</span>
628
-        <a href="#" style="float: right;" onclick="$('#requests').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Show</a>
628
+        <a toggle-target="#requests" toggle-replace="Hide" style="float: right;" class="brackets">Show</a>
629 629
       </div>
630 630
       <table id="requests" class="request_table hidden">
631 631
         <tr class="colhead">
@@ -674,7 +674,7 @@ if (count($Collages) > 0) {
674 674
     $Range = range(0, count($Collages) - 1);
675 675
     shuffle($Range);
676 676
     $Indices = array_slice($Range, 0, MAX_COLLAGES);
677
-    $SeeAll = ' <a href="#" onclick="$(\'.collage_rows\').gtoggle(); return false;">(See all)</a>';
677
+    $SeeAll = ' <a toggle-target=".collage_rows">(See all)</a>';
678 678
   } else {
679 679
     $Indices = range(0, count($Collages) - 1);
680 680
     $SeeAll = '';
@@ -725,7 +725,7 @@ if (count($PersonalCollages) > 0) {
725 725
     $Range = range(0,count($PersonalCollages) - 1);
726 726
     shuffle($Range);
727 727
     $Indices = array_slice($Range, 0, MAX_PERS_COLLAGES);
728
-    $SeeAll = ' <a href="#" onclick="$(\'.personal_rows\').gtoggle(); return false;">(See all)</a>';
728
+    $SeeAll = ' <a toggle-target=".personal_rows">(See all)</a>';
729 729
   } else {
730 730
     $Indices = range(0, count($PersonalCollages) - 1);
731 731
     $SeeAll = '';
@@ -769,8 +769,8 @@ include(SERVER_ROOT.'/sections/torrents/voter_picks.php');
769 769
 <?
770 770
     if (count($Screenshots) > 0) {
771 771
 ?>
772
-    <a style="float: right;" class='brackets' onclick="$('.torrent_screenshots').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide');">Show</a>
773
-<?   }
772
+    <a style="float: right;" class='brackets' toggle-target=".torrent_screenshots" toggle-replace="Hide">Show</a>
773
+<?  }
774 774
 
775 775
     $DB->query("
776 776
       SELECT UserID

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

@@ -403,7 +403,7 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
403 403
 <?  } ?>
404 404
               | <a href="torrents.php?torrentid=<?=($TorrentID)?>" class="tooltip" title="Permalink">PL</a>
405 405
             ]</span>
406
-            &raquo; <a href="#" onclick="$('#torrent_<?=($TorrentID)?>').gtoggle(); return false;"><?=($ExtraInfo)?></a>
406
+            &raquo; <a toggle-target="#torrent_<?=($TorrentID)?>"><?=($ExtraInfo)?></a>
407 407
           </td>
408 408
           <td class="number_column nobr"><?=(Format::get_size($Size))?></td>
409 409
           <td class="number_column"><?=(number_format($Snatched))?></td>

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

@@ -39,7 +39,7 @@ if (count($Top10) > 0) {
39 39
 ?>
40 40
     <table class="box vote_matches_table" id="vote_matches">
41 41
       <tr class="colhead">
42
-        <td><a href="#">&uarr;</a>&nbsp;People who like this also liked... <a href="#" onclick="$('.votes_rows').gtoggle(); return false;" class="brackets" style="float: right;">Toggle</a></td>
42
+        <td><a href="#">&uarr;</a>&nbsp;People who like this also liked... <a toggle-target=".votes_rows" class="brackets" style="float: right;">Toggle</a></td>
43 43
       </tr>
44 44
 <?
45 45
   $Top10Groups = array_keys($Top10);

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

@@ -112,7 +112,7 @@ $HideDNU = check_perms('torrents_hide_dnu') && !$NewDNU;
112 112
   <p><?=$NewDNU ? '<strong class="important_text">' : '' ?>Last updated: <?=time_diff($Updated)?><?=$NewDNU ? '</strong>' : '' ?></p>
113 113
   <p>The following releases are currently forbidden from being uploaded to the site. Do not upload them unless your torrent meets a condition specified in the comment.
114 114
 <?  if ($HideDNU) { ?>
115
-  <span id="showdnu"><a href="#" onclick="$('#dnulist').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Show</a></span>
115
+  <span id="showdnu"><a toggle-target="#dnulist" toggle-replace="Hide" class="brackets">Show</a></span>
116 116
 <?  } ?>
117 117
   </p>
118 118
   <table id="dnulist" class="<?=($HideDNU ? 'hidden' : '')?>">

+ 1
- 1
sections/user/linkedfunctions.php View File

@@ -197,7 +197,7 @@ function user_dupes_table($UserID) {
197 197
       <input type="hidden" id="form_comment_hash" name="form_comment_hash" value="<?=$CommentHash?>" />
198 198
       <div class="box box2" id="l_a_box">
199 199
         <div class="head">
200
-          Linked Accounts (<?=max($DupeCount - 1, 0)?>) <span style="float: right;"><a href="#" onclick="$('.linkedaccounts').gtoggle(); return false;" class="brackets">Toggle</a></span>
200
+          Linked Accounts (<?=max($DupeCount - 1, 0)?>) <span style="float: right;"><a toggle-target=".linkedaccounts" class="brackets">Toggle</a></span>
201 201
         </div>
202 202
         <table width="100%" class="layout hidden linkedaccounts">
203 203
           <?=($DupeCount ? "<tr>\n" : '')?>

+ 1
- 1
sections/user/notify_edit.php View File

@@ -89,7 +89,7 @@ foreach ($Notifications as $N) { // $N stands for Notifications
89 89
     <a href="feeds.php?feed=torrents_notify_<?=$N['ID']?>_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode($N['Label'])?>"><img src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>
90 90
     <?=display_str($N['Label'])?>
91 91
     <a href="user.php?action=notify_delete&amp;id=<?=$N['ID']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this notification filter?')" class="brackets">Delete</a>
92
-    <a href="#" onclick="$('#filter_<?=$N['ID']?>').gtoggle(); return false;" class="brackets">Show</a>
92
+    <a toggle-target="#filter_<?=$N['ID']?>" class="brackets">Show</a>
93 93
   </h3>
94 94
 <?  } ?>
95 95
   <form class="box pad slight_margin <?=($NewFilter ? 'create_form' : 'edit_form')?>" id="<?=($NewFilter ? 'filter_form' : '')?>" name="notification" action="user.php" method="post">

+ 6
- 6
sections/user/user.php View File

@@ -646,7 +646,7 @@ if ($RatioWatchEnds != '0000-00-00 00:00:00'
646 646
     <div class="box">
647 647
       <div class="head">
648 648
         <?=!empty($InfoTitle) ? $InfoTitle : 'Profile';?>
649
-        <span style="float: right;"><a href="#" onclick="$('#profilediv').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Hide</a></span>&nbsp;
649
+        <span style="float: right;"><a toggle-target="#profilediv" toggle-replace="Show" class="brackets">Hide</a></span>&nbsp;
650 650
       </div>
651 651
       <div class="pad profileinfo" id="profilediv">
652 652
 <?
@@ -778,7 +778,7 @@ foreach ($Collages as $CollageInfo) {
778 778
     <div class="head">
779 779
       <?=display_str($CName)?> - <a href="collages.php?id=<?=$CollageID?>" class="brackets">See full</a>
780 780
       <span style="float: right;">
781
-        <a href="#" onclick="$('#collage<?=$CollageID?>_box .images').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?=$FirstCol ? 'Hide' : 'Show' ?></a>
781
+        <a toggle-target="#collage<?=$CollageID?>_box .images" toggle-replace="<?=$FirstCol ? 'Show' : 'Hide' ?>" class="brackets"><?=$FirstCol ? 'Hide' : 'Show' ?></a>
782 782
       </span>
783 783
     </div>
784 784
     <div id="user_collage_images" class="collage_images">
@@ -828,7 +828,7 @@ if ((check_perms('users_view_invites')) && $Invited > 0) {
828 828
 ?>
829 829
     <div class="box" id="invitetree_box">
830 830
       <div class="head">
831
-        Invite Tree <span style="float: right"><a href="#" onclick="$('#invitetree').gtoggle(); return false;" class="brackets">Toggle</a></span>
831
+        Invite Tree <span style="float: right"><a toggle-target="#invitetree" class="brackets">Toggle</a></span>
832 832
       </div>
833 833
       <div id="invitetree" class="hidden">
834 834
 <?        $Tree->make_tree(); ?>
@@ -857,7 +857,7 @@ if (empty($LoggedUser['DisableRequests']) && check_paranoia_here('requestsvoted_
857 857
 ?>
858 858
     <div class="box" id="requests_box">
859 859
       <div class="head">
860
-        Requests <span style="float: right;"><a href="#" onclick="$('#requests').gtoggle(); return false;" class="brackets">Show</a></span>
860
+        Requests <span style="float: right;"><a toggle-target="#requests" class="brackets">Show</a></span>
861 861
       </div>
862 862
       <div id="requests" class="hidden">
863 863
         <table cellpadding="6" cellspacing="1" border="0" width="100%">
@@ -951,7 +951,7 @@ if (check_perms('users_mod', $Class) || $IsFLS) {
951 951
 ?>
952 952
     <div class="box" id="staffpms_box">
953 953
       <div class="head">
954
-        Staff PMs <a href="#" onclick="$('#staffpms').gtoggle(); return false;" class="brackets" style="float:right;">Toggle</a>
954
+        Staff PMs <a toggle-target="#staffpms" class="brackets" style="float:right;">Toggle</a>
955 955
       </div>
956 956
       <table width="100%" class="message_table hidden" id="staffpms">
957 957
         <tr class="colhead">
@@ -1026,7 +1026,7 @@ if (check_perms('users_mod', $Class)) { ?>
1026 1026
         Staff Notes
1027 1027
         <a href="#" name="admincommentbutton" onclick="ChangeTo('text'); return false;" class="brackets">Edit</a>
1028 1028
         <span style="float: right;">
1029
-        <a href="#" onclick="$('#staffnotes').gtoggle(); return false;" class="brackets">Toggle</a>
1029
+        <a toggle-target="#staffnotes" class="brackets">Toggle</a>
1030 1030
         </span>
1031 1031
       </div>
1032 1032
       <div id="staffnotes" class="pad">

+ 2
- 2
sections/userhistory/email_history2.php View File

@@ -283,7 +283,7 @@ if ($Old ?? false) {
283 283
     $Record['IP'] = apc_exists('DBKEY') ? DBCrypt::decrypt($Record['IP']) : '[Encrypted]';
284 284
 ?>
285 285
     <tr class="row">
286
-      <td><?=display_str($Record['Email'])?><?=(($MatchCount > 0) ? ' <a href="#" onclick="$(\'#matches_'.$j.'\').gtoggle(); return false;">('.$MatchCount.')</a>' : '')?></td>
286
+      <td><?=display_str($Record['Email'])?><?=(($MatchCount > 0) ? ' <a toggle-target="#matches_'.$j.'">('.$MatchCount.')</a>' : '')?></td>
287 287
       <td><?=time_diff($Record['StartTime'])?></td>
288 288
       <td><?=time_diff($Record['EndTime'])?></td>
289 289
       <td><?=time_diff($Record['ElapsedTime'])?></td>
@@ -353,7 +353,7 @@ $Invite['Email'] = apc_exists('DBKEY') ? DBCrypt::decrypt($Invite['Email']) : '[
353 353
 $Invite['IP'] = apc_exists('DBKEY') ? DBCrypt::decrypt($Invite['IP']) : '[Encrypted]';
354 354
 ?>
355 355
     <tr class="row">
356
-      <td><?=display_str($Invite['Email'])?><?=(($MatchCount > 0) ? ' <a href="#" onclick="$(\'#matches_invite\').gtoggle(); return false;">('.$MatchCount.')</a>' : '')?></td>
356
+      <td><?=display_str($Invite['Email'])?><?=(($MatchCount > 0) ? ' <a toggle-target="#matches_invite">('.$MatchCount.')</a>' : '')?></td>
357 357
       <td>Never</td>
358 358
       <td><?=time_diff($Invite['EndTime'])?></td>
359 359
       <td><?=time_diff($Invite['AccountAge'])?></td>

+ 1
- 1
sections/userhistory/subscribed_collages.php View File

@@ -252,7 +252,7 @@ if (!$NumResults) {
252 252
           <strong><a href="collage.php?id=<?=$CollageID?>"><?=$CollageName?></a></strong> (<?=$NewTorrentCount?> new torrent<?=($NewTorrentCount == 1 ? '' : 's')?>)
253 253
         </span>&nbsp;
254 254
         <span style="float: right;">
255
-          <a href="#" onclick="$('#discog_table_<?=$CollageID?>').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?=($ShowAll ? 'Show' : 'Hide')?></a>&nbsp;&nbsp;&nbsp;<a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;collageid=<?=$CollageID?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="CollageSubscribe(<?=$CollageID?>); return false;" id="subscribelink<?=$CollageID?>" class="brackets">Unsubscribe</a>
255
+          <a toggle-target="#discog_table_<?=$CollageID?>" toggle-replace="<?=($ShowAll ? 'Hide' : 'Show')?>" class="brackets"><?=($ShowAll ? 'Show' : 'Hide')?></a>&nbsp;&nbsp;&nbsp;<a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;collageid=<?=$CollageID?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="CollageSubscribe(<?=$CollageID?>); return false;" id="subscribelink<?=$CollageID?>" class="brackets">Unsubscribe</a>
256 256
         </span>
257 257
       </td>
258 258
     </tr>

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

@@ -210,4 +210,13 @@ $(function() {
210 210
     var a = $('[cover]')[0]
211 211
     if (a) preload(a.attributes.cover.value)
212 212
   }
213
+
214
+  document.querySelectorAll('[toggle-target]').forEach(function(el) {
215
+    el.addEventListener('click', function(event) {
216
+      $(el.attributes['toggle-target'].value).gtoggle()
217
+      if (el.attributes['toggle-replace']) {
218
+        [el.innerHTML, el.attributes['toggle-replace'].value] = [el.attributes['toggle-replace'].value, el.innerHTML]
219
+      }
220
+    })
221
+  })
213 222
 })

+ 2
- 2
static/functions/news_ajax.js View File

@@ -32,9 +32,9 @@ function news_ajax(event, count, offset, privileged) {
32 32
           }));
33 33
           // I'm so happy with this condition statement.
34 34
           if (privileged) {
35
-            $('#news' + this[0]).append('<div class="head"><strong>' + this[1] + '</strong> ' + this[2] + ' - <a href="tools.php?action=editnews&amp;id=' + this[0] + '" class="brackets">Edit</a><span style="float: right;"><a class="brackets" onclick="$(\'#newsbody' + this[0] + '\').gtoggle(); this.innerHTML=(this.innerHTML == \'Hide\' ? \'Show\' : \'Hide\'); return false;" href="#">Hide</a></span></div>');
35
+            $('#news' + this[0]).append('<div class="head"><strong>' + this[1] + '</strong> ' + this[2] + ' - <a href="tools.php?action=editnews&amp;id=' + this[0] + '" class="brackets">Edit</a><span style="float: right;"><a class="brackets" toggle-target="#newsbody' + this[0] + '" toggle-replace="Show">Hide</a></span></div>');
36 36
           } else {
37
-            $('#news' + this[0]).append('<div class="head"><strong>' + this[1] + '</strong> ' + this[2] + '<span style="float: right;"><a class="brackets" onclick="$(\'#newsbody' + this[0] + '\').gtoggle(); this.innerHTML=(this.innerHTML == \'Hide\' ? \'Show\' : \'Hide\'); return false;" href="#">Hide</a></span></div>');
37
+            $('#news' + this[0]).append('<div class="head"><strong>' + this[1] + '</strong> ' + this[2] + '<span style="float: right;"><a class="brackets" toggle-target="#newsbody' + this[0] + '" toggle-replace="Show">Hide</a></span></div>');
38 38
           }
39 39
           $('#news' + this[0]).append('<div class="pad" id="newsbody'+this[0]+'">' + this[3] + '</div>');
40 40
         });

+ 4
- 0
static/styles/global.css View File

@@ -96,6 +96,10 @@ div.collage_image {
96 96
   width: 20%;
97 97
 }
98 98
 
99
+[toggle-target] {
100
+  cursor: pointer;
101
+}
102
+
99 103
 button, input[type=button], input[type=submit] {
100 104
   cursor: pointer;
101 105
   background: #fff;

Loading…
Cancel
Save