MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-tooltip / core-tooltip-extracted.js
blob6f1a19a5ba84a62acdd8bc0b5b2b89c851ad7eb1
3 Polymer('core-tooltip', {
5 /**
6 * A simple string label for the tooltip to display. To display a rich
7 * that includes HTML, use the `tip` attribute on the content.
9 * @attribute label
10 * @type string
11 * @default null
13 label: null,
15 /**
16 * If true, the tooltip an arrow pointing towards the content.
18 * @attribute noarrow
19 * @type boolean
20 * @default false
22 noarrow: false,
24 /**
25 * If true, the tooltip displays by default.
27 * @attribute show
28 * @type boolean
29 * @default false
31 show: false,
33 /**
34 * Positions the tooltip to the top, right, bottom, left of its content.
36 * @attribute position
37 * @type string
38 * @default 'bottom'
40 position: 'bottom',
42 attached: function() {
43 this.setPosition();
46 labelChanged: function(oldVal, newVal) {
47 // Run if we're not after attached().
48 if (oldVal) {
49 this.setPosition();
53 setPosition: function() {
54 var controlWidth = this.clientWidth;
55 var controlHeight = this.clientHeight;
57 var styles = getComputedStyle(this.$.tooltip);
58 var toolTipWidth = parseFloat(styles.width);
59 var toolTipHeight = parseFloat(styles.height);
61 switch (this.position) {
62 case 'top':
63 case 'bottom':
64 this.$.tooltip.style.left = (controlWidth - toolTipWidth) / 2 + 'px';
65 break;
66 case 'left':
67 case 'right':
68 this.$.tooltip.style.top = (controlHeight - toolTipHeight) / 2 + 'px';
69 break;
72 });