From 22287cd3d361dcf1702cd5e0bc72f92e12205663 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 12 Nov 2013 11:53:38 -0800 Subject: [PATCH] Make tools disable correctly * Respect disabled state when handling clicks * Style disabled tools in lists correctly Change-Id: I14dffa3248ffa5d32403c6145381cfabdc2d7ff1 --- modules/oojs-ui/OO.ui.ToolGroup.js | 9 ++++++--- modules/oojs-ui/styles/OO.ui.ToolGroup.css | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/oojs-ui/OO.ui.ToolGroup.js b/modules/oojs-ui/OO.ui.ToolGroup.js index 9b81ee9b72..8bc1e8b7b3 100644 --- a/modules/oojs-ui/OO.ui.ToolGroup.js +++ b/modules/oojs-ui/OO.ui.ToolGroup.js @@ -186,11 +186,14 @@ OO.ui.ToolGroup.prototype.onMouseOut = function ( e ) { * @returns {OO.ui.Tool|null} Tool, `null` if none was found */ OO.ui.ToolGroup.prototype.getTargetTool = function ( e ) { - var $item = this.$( e.target ).closest( '.oo-ui-tool-link' ); + var tool, + $item = this.$( e.target ).closest( '.oo-ui-tool-link' ); + if ( $item.length ) { - return $item.parent().data( 'oo-ui-tool' ); + tool = $item.parent().data( 'oo-ui-tool' ); } - return null; + + return tool && !tool.isDisabled() ? tool : null; }; /** diff --git a/modules/oojs-ui/styles/OO.ui.ToolGroup.css b/modules/oojs-ui/styles/OO.ui.ToolGroup.css index aee7f179aa..0e20b9a36b 100644 --- a/modules/oojs-ui/styles/OO.ui.ToolGroup.css +++ b/modules/oojs-ui/styles/OO.ui.ToolGroup.css @@ -236,10 +236,14 @@ border-color: rgba(0,0,0,0.2); } -.oo-ui-listToolGroup .oo-ui-tool.oo-ui-widget-disabled { +.oo-ui-listToolGroup .oo-ui-tool.oo-ui-widget-disabled .oo-ui-tool-link { cursor: default; } +.oo-ui-listToolGroup .oo-ui-tool.oo-ui-widget-disabled .oo-ui-tool-link .oo-ui-labeledElement-label { + color: #ccc; +} + .oo-ui-listToolGroup .oo-ui-tool.oo-ui-widget-disabled .oo-ui-tool-link .oo-ui-iconedElement-icon { opacity: 0.2; }