Permalink
Browse files

Added tooltip support for commands and search panel

  • Loading branch information...
1 parent e21bbfd commit e92ebc61484eb3fdbf0f3ebe6e9234c12c118764 @gatapia gatapia committed May 22, 2012
Showing with 22 additions and 6 deletions.
  1. +9 −1 src/pn/ui/grid/Command.js
  2. +13 −5 src/pn/ui/srch/SearchPanel.js
View
@@ -15,8 +15,9 @@ goog.require('pn.ui.grid.Grid.EventType');
* @param {string} name The name/caption of this column.
* @param {pn.ui.grid.Grid.EventType} eventType The event to fire on '
* componenet action.
+ * @param {string=} opt_tooltip The optional tooltip for this command.
*/
-pn.ui.grid.Command = function(name, eventType) {
+pn.ui.grid.Command = function(name, eventType, opt_tooltip) {
goog.asserts.assert(name);
goog.asserts.assert(eventType);
@@ -29,6 +30,12 @@ pn.ui.grid.Command = function(name, eventType) {
this.name_ = name;
/**
+ * @private
+ * @type {string}
+ */
+ this.tooltip_ = opt_tooltip || name;
+
+ /**
* @type {pn.ui.grid.Grid.EventType}
*/
this.eventType = eventType;
@@ -58,6 +65,7 @@ pn.ui.grid.Command.prototype.createDom = function() {
pn.ui.grid.Command.prototype.decorateInternal = function(element) {
this.setElementInternal(element);
this.commandElement_ = new goog.ui.Button(this.name_);
+ this.commandElement_.setTooltip(this.tooltip_);
this.commandElement_.enableClassName(
goog.string.removeAll(this.name_.toLowerCase(), ''), true);
this.commandElement_.render(element);
@@ -141,8 +141,11 @@ pn.ui.srch.SearchPanel.prototype.decorateInternal = function(element) {
this.setElementInternal(element);
var visible = goog.net.cookies.get('search-panel-visible') !== 'false';
- var msg = visible ? 'Hide Filters' : 'Show Filters';
- this.toggle_ = goog.dom.createDom('a', 'search-toggle', msg);
+ var msg = (visible ? 'Hide' : 'Show') + ' Filters';
+ var title = 'Click to ' + (visible ? 'hide' : 'show') + ' the filters panel.';
+ this.toggle_ = goog.dom.createDom('a', {
+ 'class': 'search-toggle',
+ 'title': title}, msg);
this.searchPanel_ = goog.dom.createDom('div', 'search-panel');
goog.style.setHeight(this.searchPanel_, visible ? 'auto' : 0);
@@ -165,10 +168,15 @@ pn.ui.srch.SearchPanel.prototype.createActionControls_ = function(parent) {
goog.dom.appendChild(this.controlsPanel_, this.select_);
this.populateFieldSelect_();
- this.clear_ = goog.dom.createDom('div', 'button clear-filters', 'Clear');
+ this.clear_ = goog.dom.createDom('div', {
+ 'class': 'button clear-filters',
+ 'title': 'Clear all filters'
+ }, 'Clear');
+ this.go_ = goog.dom.createDom('div', {
+ 'class': 'button go-filters',
+ 'title': 'Go!'
+ }, 'Go');
goog.dom.appendChild(this.controlsPanel_, this.clear_);
-
- this.go_ = goog.dom.createDom('div', 'button go-filters', 'Go!');
goog.dom.appendChild(this.controlsPanel_, this.go_);
};

0 comments on commit e92ebc6

Please sign in to comment.