Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

fix(mdPanel): Panel and tooltip theming #10031

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/components/panel/panel-theme.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.md-panel {

background-color: '{{background-900-0.0}}';

&._md-panel-backdrop.md-THEME_NAME-theme {
background-color: '{{background-900-1.0}}';
}

._md-panel-backdrop.md-THEME_NAME-theme {
background-color: '{{background-900-1.0}}';
}
50 changes: 37 additions & 13 deletions src/components/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,15 @@ angular
* @returns {!MdPanelRef}
*/

/**
* @ngdoc method
* @name MdPanelRef#updateAnimation
* @description
* Updates the animation configuration for a panel. You can use this to change
* the panel's animation without having to re-create it.
*
* @param {!MdPanelAnimation} animation
*/
/**
* @ngdoc method
* @name MdPanelRef#updateAnimation
* @description
* Updates the animation configuration for a panel. You can use this to change
* the panel's animation without having to re-create it.
*
* @param {!MdPanelAnimation} animation
*/


/*****************************************************************************
Expand Down Expand Up @@ -1108,6 +1108,9 @@ function MdPanelRef(config, $injector) {
/** @private @const {!angular.$mdUtil} */
this._$mdUtil = $injector.get('$mdUtil');

/** @private @const {!angular.$mdTheming} */
this._$mdTheming = $injector.get('$mdTheming');

/** @private @const {!angular.Scope} */
this._$rootScope = $injector.get('$rootScope');

Expand Down Expand Up @@ -1650,7 +1653,8 @@ MdPanelRef.prototype._createPanel = function() {


/**
* Adds the styles for the panel, such as positioning and z-index.
* Adds the styles for the panel, such as positioning and z-index. Also,
* themes the panel element and panel container using `$mdTheming`.
* @returns {!angular.$q.Promise<!MdPanelRef>}
* @private
*/
Expand All @@ -1661,9 +1665,13 @@ MdPanelRef.prototype._addStyles = function() {
self.panelEl.css('z-index', self.config['zIndex'] + 1);

var hideAndResolve = function() {
// Theme the element and container.
self._setTheming();

// Remove left: -9999px and add hidden class.
self.panelEl.css('left', '');
self.panelContainer.addClass(MD_PANEL_HIDDEN);

resolve(self);
};

Expand All @@ -1679,17 +1687,31 @@ MdPanelRef.prototype._addStyles = function() {
return; // Don't setup positioning.
}

// Wait for angular to finish processing the template, then position it
// correctly. This is necessary so that the panel will have a defined height
// and width.
// Wait for angular to finish processing the template
self._$rootScope['$$postDigest'](function() {
// Position it correctly. This is necessary so that the panel will have a
// defined height and width.
self._updatePosition(true);

// Theme the element and container.
self._setTheming();

resolve(self);
});
});
};


/**
* Sets the `$mdTheming` classes on the `panelContainer` and `panelEl`.
* @private
*/
MdPanelRef.prototype._setTheming = function() {
this._$mdTheming(this.panelEl);
this._$mdTheming(this.panelContainer);
};


/**
* Updates the position configuration of a panel
* @param {!MdPanelPosition} position
Expand Down Expand Up @@ -2210,6 +2232,7 @@ MdPanelRef.prototype.removeFromGroup = function(groupName) {
}
};


/**
* Possible default closeReasons for the close function.
* @enum {string}
Expand All @@ -2219,6 +2242,7 @@ MdPanelRef.closeReasons = {
ESCAPE: 'escapeToClose',
};


/*****************************************************************************
* MdPanelPosition *
*****************************************************************************/
Expand Down
6 changes: 2 additions & 4 deletions src/components/tooltip/tooltip-theme.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.md-tooltip.md-THEME_NAME-theme {
.md-panel.md-tooltip.md-THEME_NAME-theme {
color: '{{background-700-contrast}}';
&.md-panel {
background-color: '{{background-700}}';
}
background-color: '{{background-700}}';
}
5 changes: 1 addition & 4 deletions src/components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ angular
* Defaults to bottom.
*/
function MdTooltipDirective($timeout, $window, $$rAF, $document, $interpolate,
$mdUtil, $mdTheming, $mdPanel, $$mdTooltipRegistry) {
$mdUtil, $mdPanel, $$mdTooltipRegistry) {

var ENTER_EVENTS = 'focus touchstart mouseenter';
var LEAVE_EVENTS = 'blur touchcancel mouseleave';
Expand Down Expand Up @@ -81,9 +81,6 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $interpolate,
var origin, position, panelPosition, panelRef, autohide, showTimeout,
elementFocusedOnWindowBlur = null;

// Initialize the theming of the tooltip.
$mdTheming(element);

// Set defaults
setDefaults();

Expand Down