Skip to content
This repository

Issue 2991 #733

Merged
merged 1 commit into from almost 2 years ago

2 participants

Larissa Reis sarken
Larissa Reis

The javascript for check_all and check_none only searched for checkboxes
in the next fieldset, which would return none since the buttons in the
bottom are the last siblings in the DOM tree and next() doesn't loop back
to the first sibling.

Changes were made so it looks also in the previous sibling.

Plus a quick fix in the view which had incorrect class names (Issue 2820)

Larissa Reis Issue 2991
  The javascript for check_all and check_none only searched for checkboxes
  in the next fieldset, which would return none since the buttons in the
  bottom are the last siblings in the DOM tree and next() doesn't loop back
  to the first sibling.

  Changes were made so it looks also in the previous sibling.

  Plus a quick fix in the view which had incorrect class names (Issue 2820)
6a8c037
sarken sarken merged commit 8d2f598 into from July 09, 2012
sarken sarken closed this July 09, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 01, 2012
Larissa Reis Issue 2991
  The javascript for check_all and check_none only searched for checkboxes
  in the next fieldset, which would return none since the buttons in the
  bottom are the last siblings in the DOM tree and next() doesn't loop back
  to the first sibling.

  Changes were made so it looks also in the previous sibling.

  Plus a quick fix in the view which had incorrect class names (Issue 2820)
6a8c037
This page is out of date. Refresh to see the latest.
8  app/views/inbox/show.html.erb
@@ -61,8 +61,8 @@
61 61
   <fieldset class="actions">
62 62
     <legend><%= ts("Mass Edit Options") %></legend>
63 63
     <ul role="menu">
64  
-      <li><a class="checkall"><%= ts("Select All") %></a></li>
65  
-      <li><a class="checknone"><%= ts("Select None") %></a></li>
  64
+      <li><a class="check_all"><%= ts("Select All") %></a></li>
  65
+      <li><a class="check_none"><%= ts("Select None") %></a></li>
66 66
       <li><%= submit_tag ts("Mark Read"), :name => 'read' %></li>
67 67
       <li><%= submit_tag ts("Mark Unread"), :name => 'unread' %></li>
68 68
       <li><%= submit_tag ts("Delete From Inbox"), :name => 'delete' %></li>
@@ -73,7 +73,7 @@
73 73
 
74 74
   <!-- we can't open comment forms inside the inbox form, which is why this is down here -->
75 75
   <!-- this div will contain the reply-to-comment form -->
76  
-  <div id="reply-to-comment" class="dynamic hidden"></div> 
  76
+  <div id="reply-to-comment" class="dynamic hidden"></div>
77 77
 <% end %>
78 78
 
79 79
 <!--/content-->
@@ -127,4 +127,4 @@
127 127
 <% end %>
128 128
 <!--/subnav-->
129 129
 
130  
-<%= will_paginate @inbox_comments %>
  130
+<%= will_paginate @inbox_comments %>
70  public/javascripts/application.js
... ...
@@ -1,5 +1,5 @@
1 1
 // Place your application-specific JavaScript functions and classes here
2  
-// This file is automatically included by javascript_include_tag :defaults 
  2
+// This file is automatically included by javascript_include_tag :defaults
3 3
 
4 4
 //things to do when the page loads
5 5
 $j(document).ready(function() {
@@ -16,9 +16,9 @@ $j(document).ready(function() {
16 16
           expandList();
17 17
           return false;
18 18
       });
19  
-    $j('#hide-notice-banner').click(function (e) { 
  19
+    $j('#hide-notice-banner').click(function (e) {
20 20
       $j('#notice-banner').hide();
21  
-      e.preventDefault(); 
  21
+      e.preventDefault();
22 22
     });
23 23
     setupTooltips();
24 24
 
@@ -93,21 +93,21 @@ jQuery(function($){
93 93
       $(this).nextAll(".shuffle").show();
94 94
       $(this).next(".contract").show();
95 95
     }
96  
-    
97  
-    // set up click event to expand the list 
  96
+
  97
+    // set up click event to expand the list
98 98
     $(this).click(function(event){
99 99
       list = $($(this).attr('action_target'));
100 100
       list.show();
101  
-      
  101
+
102 102
       // show the contract & shuffle buttons and hide us
103 103
       $(this).next(".contract").show();
104 104
       $(this).nextAll(".shuffle").show();
105 105
       $(this).hide();
106  
-      
  106
+
107 107
       event.preventDefault(); // don't want to actually click the link
108 108
     });
109 109
   });
110  
-  
  110
+
111 111
   $('.contract').each(function(){
112 112
     $(this).click(function(event){
113 113
       // hide the list when clicked
@@ -118,11 +118,11 @@ jQuery(function($){
118 118
       $(this).prev(".expand").show();
119 119
       $(this).nextAll(".shuffle").hide();
120 120
       $(this).hide();
121  
-      
  121
+
122 122
       event.preventDefault(); // don't want to actually click the link
123 123
     });
124 124
   });
125  
-  
  125
+
126 126
   $('.shuffle').each(function(){
127 127
     // shuffle the list's children when clicked
128 128
     $(this).click(function(event){
@@ -131,28 +131,28 @@ jQuery(function($){
131 131
       event.preventDefault(); // don't want to actually click the link
132 132
     });
133 133
   });
134  
-  
  134
+
135 135
   $('.expand_all').each(function(){
136 136
       target = "." + $(this).attr('target_class');
137 137
      $(this).click(function(event) {
138 138
         $(this).closest(target).find(".expand").click();
139 139
         event.preventDefault();
140  
-     }); 
  140
+     });
141 141
   });
142  
-  
  142
+
143 143
   $('.contract_all').each(function(){
144 144
      target = "." + $(this).attr('target_class');
145 145
      $(this).click(function(event) {
146 146
         $(this).closest(target).find(".contract").click();
147 147
         event.preventDefault();
148  
-     }); 
  148
+     });
149 149
   });
150  
-  
  150
+
151 151
 });
152 152
 
153 153
 // check all or none within the parent fieldset, optionally with a string to match on the name field of the checkboxes
154 154
 // stored in the "checkbox_name_filter" attribute on the all/none links.
155  
-// allow for some flexibility by checking the next fieldset if the checkboxes aren't in this one
  155
+// allow for some flexibility by checking the next and previous fieldset if the checkboxes aren't in this one
156 156
 jQuery(function($){
157 157
   $('.check_all').each(function(){
158 158
     $(this).click(function(event){
@@ -162,13 +162,18 @@ jQuery(function($){
162 162
         checkboxes = $(this).closest('fieldset').find('input[name*="' + filter + '"][type="checkbox"]');
163 163
       } else {
164 164
         checkboxes = $(this).closest("fieldset").find(':checkbox');
165  
-        if (checkboxes.length == 0) { checkboxes = $(this).closest("fieldset").next().find(':checkbox'); }
  165
+        if (checkboxes.length == 0) {
  166
+          checkboxes = $(this).closest("fieldset").next().find(':checkbox');
  167
+          if (checkboxes.length == 0) {
  168
+            checkboxes = $(this).closest("fieldset").prev().find(':checkbox');
  169
+          }
  170
+        }
166 171
       }
167 172
       checkboxes.attr('checked', true);
168 173
       event.preventDefault();
169 174
     });
170 175
   });
171  
-  
  176
+
172 177
   $('.check_none').each(function(){
173 178
     $(this).click(function(event){
174 179
       var filter = $(this).attr('checkbox_name_filter');
@@ -177,7 +182,12 @@ jQuery(function($){
177 182
         checkboxes = $(this).closest('fieldset').find('input[name*="' + filter + '"][type="checkbox"]');
178 183
       } else {
179 184
         checkboxes = $(this).closest("fieldset").find(':checkbox');
180  
-        if (checkboxes.length == 0) { checkboxes = $(this).closest("fieldset").next().find(':checkbox'); }
  185
+        if (checkboxes.length == 0) {
  186
+          checkboxes = $(this).closest("fieldset").next().find(':checkbox');
  187
+          if (checkboxes.length == 0) {
  188
+            checkboxes = $(this).closest("fieldset").prev().find(':checkbox');
  189
+          }
  190
+        }
181 191
       }
182 192
       checkboxes.attr('checked', false);
183 193
       event.preventDefault();
@@ -204,7 +214,7 @@ jQuery(function($) {
204 214
 //   foo!
205 215
 //   <a class="foo_close hidden">Close</a>
206 216
 // </div>
207  
-// 
  217
+//
208 218
 // Notes:
209 219
 // - The open button CANNOT be inside the toggled div, the close button can be (but doesn't have to be)
210 220
 // - You can have multiple open and close buttons for the same div since those are labeled with classes
@@ -216,7 +226,7 @@ function setupToggled(){
216 226
     var node = $j(this);
217 227
     var open_toggles = $j('.' + node.attr('id') + "_open");
218 228
     var close_toggles = $j('.' + node.attr('id') + "_close");
219  
-    
  229
+
220 230
     if (!node.hasClass('open')) {node.hide();}
221 231
     close_toggles.each(function(){$j(this).hide();});
222 232
     open_toggles.each(function(){$j(this).show();});
@@ -229,7 +239,7 @@ function setupToggled(){
229 239
         close_toggles.each(function(){$j(this).show();});
230 240
       });
231 241
     });
232  
-    
  242
+
233 243
     close_toggles.each(function(){
234 244
       $j(this).click(function(e){
235 245
         if ($j(this).attr('href') == '#') {e.preventDefault();}
@@ -238,7 +248,7 @@ function setupToggled(){
238 248
         open_toggles.each(function(){$j(this).show();});
239 249
       });
240 250
     });
241  
-  });  
  251
+  });
242 252
 }
243 253
 
244 254
 
@@ -261,10 +271,10 @@ function handlePopUps() {
261 271
       if (event.stopped) return;
262 272
       window.open($j(element).attr('href'));
263 273
       event.stop();
264  
-    });    
  274
+    });
265 275
 }
266 276
 
267  
-// used in nested form fields for deleting a nested resource 
  277
+// used in nested form fields for deleting a nested resource
268 278
 // see prompt form for example
269 279
 function remove_section(link, class_of_section_to_remove) {
270 280
     $j(link).siblings(":input[type=hidden]").val("1"); // relies on the "_destroy" field being the nearest hidden field
@@ -274,7 +284,7 @@ function remove_section(link, class_of_section_to_remove) {
274 284
 // used with nested form fields for dynamically stuffing in an extra partial
275 285
 // see challenge signup form and prompt form for an example
276 286
 function add_section(link, nested_model_name, content) {
277  
-    // get the right new_id which should be in a div with class "last_id" at the bottom of 
  287
+    // get the right new_id which should be in a div with class "last_id" at the bottom of
278 288
     // the nearest section
279 289
     var last_id = parseInt($j(link).parent().siblings('.last_id').last().html());
280 290
     var new_id = last_id + 1;
@@ -288,10 +298,10 @@ function add_section(link, nested_model_name, content) {
288 298
 // An attempt to replace the various work form toggle methods with a more generic one
289 299
 function toggleFormField(element_id) {
290 300
     var ticky = $j('#' + element_id + '-show');
291  
-    if (ticky.is(':checked')) { 
292  
-      $j('#' + element_id).removeClass('hidden'); 
  301
+    if (ticky.is(':checked')) {
  302
+      $j('#' + element_id).removeClass('hidden');
293 303
     }
294  
-    else { 
  304
+    else {
295 305
         $j('#' + element_id).addClass('hidden');
296 306
         if (element_id != 'chapters-options') {
297 307
             $j('#' + element_id).find(':input[type!="hidden"]').each(function(index, d) {
@@ -338,7 +348,7 @@ function updateCharacterCounter(counter) {
338 348
     var input_id = '#' + $j(counter).attr('id');
339 349
     var maxlength = $j(input_id + '_counter').attr('data-maxlength');
340 350
     var input_value = $j(input_id).val();
341  
-    input_value = (input_value.replace(/\r\n/g,'\n')).replace(/\r|\n/g,'\r\n'); 
  351
+    input_value = (input_value.replace(/\r\n/g,'\n')).replace(/\r|\n/g,'\r\n');
342 352
     var remaining_characters = maxlength - input_value.length;
343 353
     $j(input_id + '_counter').html(remaining_characters);
344 354
     $j(input_id + '_counter').attr("aria-valuenow", remaining_characters);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.