• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
Hopefully a little optimization
Line 99: Line 99:  
             //set the new state of the multi toggle.
 
             //set the new state of the multi toggle.
 
             if (selected && property_states.indexOf(selected) >= 0) {
 
             if (selected && property_states.indexOf(selected) >= 0) {
 +
                //If the selected filter was re-selected, that is a remove filter action.
 
                 if ((property_filter && multiToggleStorage.on(selected))) {
 
                 if ((property_filter && multiToggleStorage.on(selected))) {
 
                     selected = "none";
 
                     selected = "none";
Line 104: Line 105:  
                 multiToggleStorage.set(selected);
 
                 multiToggleStorage.set(selected);
 
             } else {
 
             } else {
 +
                //No selection, so we are initializing the multi toggle.
 
                 selected = multiToggleStorage.get()
 
                 selected = multiToggleStorage.get()
 
             }
 
             }
 
             //Update non-selected states
 
             //Update non-selected states
 +
            var hide_selectors = [];
 +
            var show_selectors = [];
 
             property_states.forEach(function(state) {
 
             property_states.forEach(function(state) {
                 var toggle_show_selector = '.multi-toggle[data-target="' + property + '"] .multi-toggle-button[data-state="' + state + '"] .multi-toggle-active',
+
                 var toggle_active_selector = '.multi-toggle[data-target="' + property + '"] .multi-toggle-button[data-state="' + state + '"] .multi-toggle-active',
                     toggle_hide_selector = '.multi-toggle[data-target="' + property + '"] .multi-toggle-button[data-state="' + state + '"] .multi-toggle-inactive';
+
                     toggle_inactive_selector = '.multi-toggle[data-target="' + property + '"] .multi-toggle-button[data-state="' + state + '"] .multi-toggle-inactive';
                 if (!multiToggleStorage.on(state)) {
+
                 if (selected !== state) {
                     $(toggle_show_selector).hide();
+
                     $(toggle_active_selector).hide();
                     $(toggle_hide_selector).show();
+
                     $(toggle_inactive_selector).show();
 
                     if (selected === "none") {
 
                     if (selected === "none") {
                         $("." + target + "-" + state).show();
+
                         show_selectors.push("." + target + "-" + state);
 
                     } else {
 
                     } else {
                         $("." + target + "-" + state).hide();
+
                         hide_selectors.push("." + target + "-" + state);
 
                     }
 
                     }
 +
                } else {
 +
                    $(toggle_active_selector).show();
 +
                    $(toggle_inactive_selector).hide();
 +
                    show_selectors.push("." + target + "-" + state);
 
                 }
 
                 }
 
             })
 
             })
 +
            $(hide_selectors.join(',')).hide();
 
             //Update selected state last
 
             //Update selected state last
             var toggle_show_selector = '.multi-toggle[data-target="' + property + '"] .multi-toggle-button[data-state="' + selected + '"] .multi-toggle-active',
+
             $(show_selectors.join(',')).show();
                toggle_hide_selector = '.multi-toggle[data-target="' + property + '"] .multi-toggle-button[data-state="' + selected + '"] .multi-toggle-inactive';
  −
            $(toggle_show_selector).show();
  −
            $(toggle_hide_selector).hide();
  −
            $("." + target + "-" + selected).show();
   
             //Update colspan for custom rows.
 
             //Update colspan for custom rows.
 
             if (property_filter) {
 
             if (property_filter) {
Anonymous user

Navigation menu