return div;
}
+ /**
+ * @private
+ * @const
+ * @type {number}
+ */
+ ExtensionErrorList.MAX_ERRORS_TO_SHOW_ = 3;
+
ExtensionErrorList.prototype = {
__proto__: HTMLDivElement.prototype,
- /**
- * @private
- * @const
- * @type {number}
- */
- MAX_ERRORS_TO_SHOW_: 3,
-
/** @override */
decorate: function() {
this.contents_ = this.querySelector('.extension-error-list-contents');
}
}, this);
- if (this.contents_.children.length > this.MAX_ERRORS_TO_SHOW_)
- this.initShowMoreButton_();
+ var numShowing = this.contents_.children.length;
+ if (numShowing > ExtensionErrorList.MAX_ERRORS_TO_SHOW_)
+ this.initShowMoreLink_();
},
/**
- * Initialize the "Show More" button for the error list. If there are more
+ * Initialize the "Show More" link for the error list. If there are more
* than |MAX_ERRORS_TO_SHOW_| errors in the list.
* @private
*/
- initShowMoreButton_: function() {
- var button = this.querySelector('.extension-error-list-show-more button');
- button.hidden = false;
- button.isShowingAll = false;
+ initShowMoreLink_: function() {
+ var link = this.querySelector(
+ '.extension-error-list-show-more [is="action-link"]');
+ link.hidden = false;
+ link.isShowingAll = false;
+
var listContents = this.querySelector('.extension-error-list-contents');
+
+ // TODO(dbeam/kalman): trade all this transition voodoo for .animate()?
listContents.addEventListener('webkitTransitionEnd', function(e) {
- if (listContents.classList.contains('active'))
+ if (listContents.classList.contains('deactivating'))
+ listContents.classList.remove('deactivating', 'active');
+ else
listContents.classList.add('scrollable');
});
- button.addEventListener('click', function(e) {
+
+ link.addEventListener('click', function(e) {
+ link.isShowingAll = !link.isShowingAll;
+
+ var message = link.isShowingAll ? 'extensionErrorsShowFewer' :
+ 'extensionErrorsShowMore';
+ link.textContent = loadTimeData.getString(message);
+
// Disable scrolling while transitioning. If the element is active,
// scrolling is enabled when the transition ends.
- listContents.classList.toggle('active');
listContents.classList.remove('scrollable');
- var message = button.isShowingAll ? 'extensionErrorsShowMore' :
- 'extensionErrorsShowFewer';
- button.textContent = loadTimeData.getString(message);
- button.isShowingAll = !button.isShowingAll;
+
+ if (link.isShowingAll) {
+ listContents.classList.add('active');
+ listContents.classList.remove('deactivating');
+ } else {
+ listContents.classList.add('deactivating');
+ }
}.bind(this));
}
};