MediaWiki:Common.js: Difference between revisions

m Use one floating page tools container
m Restore floating expand collapse controls
 
Line 49: Line 49:
     function findCollapsibles($root) {
     function findCollapsibles($root) {
         return $root
         return $root
             .find('.mw-collapsible.mw-made-collapsible')
             .find('.mw-collapsible')
             .add($root.filter('.mw-collapsible.mw-made-collapsible'));
             .add($root.filter('.mw-collapsible'));
     }
     }


Line 59: Line 59:
         $expand.prop('disabled', $items.length === 0 || collapsedCount === 0);
         $expand.prop('disabled', $items.length === 0 || collapsedCount === 0);
         $collapse.prop('disabled', $items.length === 0 || collapsedCount === $items.length);
         $collapse.prop('disabled', $items.length === 0 || collapsedCount === $items.length);
    }
    function triggerFallback($element, collapse) {
        if ($element.hasClass('mw-collapsed') === collapse) {
            return;
        }
        $element.find('> .muhro-early-toggle, .muhro-early-toggle').first().trigger('click');
     }
     }


Line 66: Line 74:
             var api = $element.data('mw-collapsible');
             var api = $element.data('mw-collapsible');


             if (!api || $element.hasClass('mw-collapsed') === collapse) {
             if ($element.hasClass('mw-collapsed') === collapse) {
                 return;
                 return;
             }
             }


             if (collapse) {
             if (api) {
                 api.collapse();
                if (collapse) {
                    api.collapse();
                 } else {
                    api.expand();
                }
             } else {
             } else {
                 api.expand();
                 triggerFallback($element, collapse);
             }
             }
         });
         });


         updateButtons($root, $expand, $collapse);
         window.setTimeout(function () {
            updateButtons($root, $expand, $collapse);
        }, 0);
     }
     }


Line 131: Line 145:
         function tryAttach() {
         function tryAttach() {
             attempts++;
             attempts++;
             if (attachControls($root) || attempts >= 20) {
             if (attachControls($root) || attempts >= 40) {
                 return;
                 return;
             }
             }