• 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
Optimization to try to enable multiple multi toggles on page without startup lag
Line 156: Line 156:     
             //Activate multi toggles.
 
             //Activate multi toggles.
 +
            var targets = {};
 
             $(".multi-toggle").each(function() {
 
             $(".multi-toggle").each(function() {
 
                 var multi_toggle_element = $(this),
 
                 var multi_toggle_element = $(this),
                     multi_toggle_buttons = multi_toggle_element.children(".multi-toggle-button");
+
                     multi_toggle_buttons = multi_toggle_element.children(".multi-toggle-button"),
 +
                    target = multi_toggle_element.data("target") || "default";
 
                 multi_toggle_element.show();
 
                 multi_toggle_element.show();
                 multi_update(multi_toggle_element);
+
                 if (!targets.hasOwnProperty(target))
 +
                    targets[target] = multi_toggle_element;
 
                 //Remove click event handlers from all multi toggle buttons
 
                 //Remove click event handlers from all multi toggle buttons
 
                 multi_toggle_buttons.off("click");
 
                 multi_toggle_buttons.off("click");
Line 168: Line 171:  
                 });
 
                 });
 
             });
 
             });
 +
            //call multi-update once for each target to allow multiple controls
 +
            //without horrible lag
 +
            Object.keys(targets).forEach(function (key) {multi_update(targets[key])});
    
             // .mw-collapsible togglers
 
             // .mw-collapsible togglers
Anonymous user

Navigation menu