Skip to content

Commit

Permalink
Added tooltip support for commands and search panel
Browse files Browse the repository at this point in the history
  • Loading branch information
gatapia committed May 22, 2012
1 parent e21bbfd commit e92ebc6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/pn/ui/grid/Command.js
Expand Up @@ -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);

Expand All @@ -28,6 +29,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}
*/
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 13 additions & 5 deletions src/pn/ui/srch/SearchPanel.js
Expand Up @@ -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);

Expand All @@ -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_);
};

Expand Down

0 comments on commit e92ebc6

Please sign in to comment.