* fixed width, but variable height. Currently the arrow is always positioned
* at the bottom right and points down.
* @constructor
- * @extends {cr.ui.div}
+ * @extends {HTMLDivElement}
+ * @implements {EventListener}
*/
var ExpandableBubble = cr.ui.define('div');
/**
* Sets the title of the bubble. The title is always visible when the
* bubble is visible.
- * @type {Node} An HTML element to set as the title.
+ * @param {Node} node An HTML element to set as the title.
*/
set contentTitle(node) {
var bubbleTitle = this.querySelector('.expandable-bubble-title');
/**
* Sets the content node of the bubble. The content node is only visible
* when the bubble is expanded.
- * @param {Node} An HTML element.
+ * @param {Node} node An HTML element.
*/
set content(node) {
var bubbleMain = this.querySelector('.expandable-bubble-main');
/**
* Handles the close event which is triggered when the close button
* is clicked. By default is set to this.hide.
- * @param {function} A function with no parameters
+ * @param {Function} func A function with no parameters.
*/
set handleCloseEvent(func) {
this.handleCloseEvent_ = func;
this.hidden = false;
}
this.bubbleSuppressed = suppress;
- this.resizeAndReposition(this);
+ this.resizeAndReposition();
},
/**
// have).
var offset = 0;
if (!this.expanded)
- offset = (clientRect.width - parseInt(this.style.width)) / 2;
+ offset = (clientRect.width - parseInt(this.style.width, 10)) / 2;
this.style.left = this.style.right = clientRect.left + offset + 'px';
var top = Math.max(0, clientRect.top - 4);
this.reposition_();
},
- /*
+ /**
* Expand the bubble (bringing the full content into view).
* @private
*/
* The onclick handler for the notification (expands the bubble).
* @param {Event} e The event.
* @private
+ * @suppress {checkTypes}
+ * TODO(vitalyp): remove suppression when the extern
+ * Node.prototype.contains() will be fixed.
*/
onNotificationClick_: function(e) {
- if (!this.contains(e.target))
+ if (!this.contains(/** @type {!Node} */(e.target)))
return;
if (!this.expanded) {
this.eventTracker_.add(this, 'click', this.onNotificationClick_);
var doc = this.ownerDocument;
- this.eventTracker_.add(doc, 'keydown', this, true);
- this.eventTracker_.add(doc, 'mousedown', this, true);
+ this.eventTracker_.add(assert(doc), 'keydown', this, true);
+ this.eventTracker_.add(assert(doc), 'mousedown', this, true);
},
/**
* necessary.
* @param {Event} e The event.
* @private
+ * @suppress {checkTypes}
+ * TODO(vitalyp): remove suppression when the extern
+ * Node.prototype.contains() will be fixed.
*/
handleEvent: function(e) {
var handled = false;
if (e.target == this.querySelector('.expandable-bubble-close')) {
this.handleCloseEvent_();
handled = true;
- } else if (!this.contains(e.target)) {
+ } else if (!this.contains(/** @type {!Node} */(e.target))) {
if (this.expanded) {
this.collapseBubble_();
handled = true;
/**
* Whether the bubble is expanded or not.
- * @type {boolean}
*/
cr.defineProperty(ExpandableBubble, 'expanded', cr.PropertyKind.BOOL_ATTR);
* to the user that part of the text is clipped. This is only used when the
* bubble is collapsed and the title doesn't fit because it is maxed out in
* width within the anchored node.
- * @type {boolean}
*/
cr.defineProperty(ExpandableBubble, 'masked', cr.PropertyKind.BOOL_ATTR);