Skip to content

Commit

Permalink
Fixed #1414 - value and disabled props for Tooltip component
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Aug 6, 2021
1 parent a5acd78 commit 9cf6404
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/components/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function onClick(event) {
}

function show(el) {
if (!el.$_ptooltipValue) {
if (el.$_ptooltipDisabled) {
return;
}

Expand All @@ -75,7 +75,9 @@ function show(el) {
tooltipElement.style.zIndex = ++DomHandler.zindex;

window.addEventListener('resize', function onWindowResize() {
hide(el);
if (!DomHandler.isAndroid()) {
hide(el);
}
this.removeEventListener('resize', onWindowResize);
});

Expand Down Expand Up @@ -237,9 +239,16 @@ function isOutOfBounds(el) {
}

const Tooltip = {
bind(el, options) {
bind(el, options) {console.log(options)
el.$_ptooltipModifiers = options.modifiers;
el.$_ptooltipValue = options.value;
if (typeof options.value === 'string') {
el.$_ptooltipValue = options.value;
el.$_ptooltipDisabled = false;
}
else {
el.$_ptooltipValue = options.value.value;
el.$_ptooltipDisabled = options.value.disabled || false;
}
bindEvents(el);
},
unbind(el) {
Expand All @@ -253,7 +262,15 @@ const Tooltip = {
},
update(el, options) {
el.$_ptooltipModifiers = options.modifiers;
el.$_ptooltipValue = options.value;

if (typeof options.value === 'string') {
el.$_ptooltipValue = options.value;
el.$_ptooltipDisabled = false;
}
else {
el.$_ptooltipValue = options.value.value;
el.$_ptooltipDisabled = options.value.disabled;
}
}
};

Expand Down
7 changes: 7 additions & 0 deletions src/views/tooltip/TooltipDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ directives: {
<template v-pre>
&lt;InputText type="text" v-tooltip="'Enter your username'" /&gt;
</template>
</CodeHighlight>

<p>Also, more than one value can be used.</p>
<CodeHighlight>
<template v-pre>
&lt;InputText type="text" v-tooltip="{ value: 'Enter your username', disabled: true }" /&gt;
</template>
</CodeHighlight>

<h5>Positions</h5>
Expand Down

0 comments on commit 9cf6404

Please sign in to comment.