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 | .find('.mw-collapsible') | ||
.add($root.filter('.mw | .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 ( | if ($element.hasClass('mw-collapsed') === collapse) { | ||
return; | return; | ||
} | } | ||
if (collapse) { | if (api) { | ||
api. | if (collapse) { | ||
api.collapse(); | |||
} else { | |||
api.expand(); | |||
} | |||
} else { | } else { | ||
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 >= | if (attachControls($root) || attempts >= 40) { | ||
return; | return; | ||
} | } | ||