-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing widget tooltip for any widget
- Loading branch information
Showing
12 changed files
with
155 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<h3 class="CDB-Widget-textBig" title="<%- title %>"><%- title %></h3> | ||
<div class="CDB-Widget-options CDB-Widget-contentSpaced"> | ||
<button class="CDB-Widget-buttonIcon CDB-Widget-buttonIcon--circle | ||
<button class="CDB-Widget-buttonIcon CDB-Widget-buttonIcon--circle js-sizes | ||
<%- isSizesApplied ? 'is-selected' : '' %> | ||
<%- isSizesApplied ? 'js-cancelSizes' : 'js-applySizes' %> | ||
"> | ||
" data-tooltip="<%- isSizesApplied ? 'Remove sizes' : 'Apply sizes' %>"> | ||
<i class="CDB-Icon CDB-Icon-syringe CDB-Icon--top"></i> | ||
</button> | ||
<button class="CDB-Shape-threePoints js-collapse"> | ||
<button class="CDB-Shape-threePoints js-collapse" data-tooltip="<%- isCollapsed ? 'Show' : 'Hide' %>"> | ||
<span class="CDB-Shape-threePointsItem"></span> | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
var View = require('cdb/core/view'); | ||
var _ = require('underscore'); | ||
|
||
/** | ||
* Standard widget tooltip view | ||
* | ||
*/ | ||
module.exports = View.extend({ | ||
|
||
className: 'CDB-Widget-tooltip', | ||
|
||
options: { | ||
attribute: 'data-tooltip', | ||
offsetX: 10, | ||
offsetY: -28 | ||
}, | ||
|
||
initialize: function(opts) { | ||
if (!opts.target) { | ||
throw new Error('target is not defined'); | ||
} | ||
this._$target = this.options.target; | ||
this._initBinds(); | ||
}, | ||
|
||
render: function() { | ||
var value = this._$target.attr(this.options.attribute); | ||
this.$el.html(value); | ||
return this; | ||
}, | ||
|
||
_initBinds: function() { | ||
this._$target.hover( | ||
_.bind(this.show, this), | ||
_.bind(this.hide, this) | ||
); | ||
}, | ||
|
||
_setPosition: function() { | ||
var pos = this._$target.offset(); | ||
var width = this.$el.outerWidth(); | ||
|
||
this.$el.css({ | ||
top: pos.top + this.options.offsetY, | ||
left: pos.left - (width/2) + this.options.offsetX | ||
}); | ||
}, | ||
|
||
show: function() { | ||
this.render(); | ||
this._setPosition(); | ||
View.prototype.show.call(this); | ||
}, | ||
|
||
clean: function() { | ||
this._$target.off('mouseenter mouseleave'); | ||
View.prototype.clean.call(this); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Tooltip styles | ||
// ---------------------------------------------- | ||
|
||
@import '../variables/mixins'; | ||
|
||
.CDB-Widget-tooltip { | ||
@include css3-prefix(user-select, none); | ||
display: none; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
min-width: 50px; | ||
max-width: 120px; | ||
padding: 5px; | ||
box-sizing: border-box; | ||
border-radius: 3px; | ||
background: #000; | ||
color: #FFF; | ||
font-family: 'Open Sans'; | ||
font-size: 10px; | ||
text-align: center; | ||
pointer-events: none; | ||
z-index: 10; | ||
} | ||
|
||
.CDB-Widget-tooltip:after { | ||
display: inline-block; | ||
position: absolute; | ||
bottom: -3px; | ||
left: 50%; | ||
margin-left: -7px; | ||
border-top: 5px solid #000; | ||
border-right: 5px solid transparent; | ||
border-left: 5px solid transparent; | ||
content: ''; | ||
} |