Add toggle property in v-b-popover for touch - vue.js

I am using v-b-popover.
My devices are touch and mouse events.
So I am using v-b-popover.hover as a tag.
So I wanted to know, Is their anyway I can toggle the popover(show and hide) in both touch and mouse events.
<b-col v-for="lesson in Lessons">
<b-button
v-b-popover.hover.bottom="lesson.lessonName">
{{lesson.lessonName}}
</b-button>
</b-col>

The tooltip's hover trigger, includes touch on mobile by default. So it should already work with no changes if all you need is touch events on mobile, and hover on desktop.
<b-button v-b-popover.hover="'Hello World!'">
A tooltip is shown on hover on desktop, and touch on mobile.
</b-button>
If you want to support mouse clicks on desktop, you'll need an additional trigger. Either click or focus should work for that.
<b-button v-b-popover.hover.click="'Hello World!'">
A tooltip is shown on hover/click on desktop, and click on mobile.
</b-button>

You can use the v-b-popover.hover.focus.bottom directive for your buttons and then all your button can be triggered by click or hover, and it meets your requirements in mobile devices and mouse events,
new Vue({
el: '#app',
mounted() {
document.getElementsByTagName('body')[0].addEventListener('click', e => {
this.$root.$emit('bv::hide::popover')
});
}
})
#app {
margin: 2rem;
}
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap#4.5.3/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap-vue#2.21.2/dist/bootstrap-vue.css" />
<script src="https://unpkg.com/vue#2.6.12/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue#2.21.2/dist/bootstrap-vue.min.js"></script>
<div id="app">
<b-button v-b-popover.hover.focus.bottom="'Hellow World!'" variant="info">Your Button</b-button>
</div>

Related

How to invoke some method on Bootstrap Vue <b-modal> X-close button

Using b-modal Bootstrap Vue component, I'am trying to invoke especific method when the user clicks on the 'X' button at the right corner of the modal window.
I've tried with #close, #closeHeader, #closeheader without success.
<b-modal ok-only #ok="methodOk" #close="methodClose">
<span>Window closed</span>
</b-modal>
The #close event is what you're after.
If it isn't working for you, i suggest you check your version of BootstrapVue, or potential errors in your console.
new Vue({
el: '#app',
methods: {
onClose() {
alert('Modal X button pressed');
}
}
})
<link href="https://unpkg.com/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://unpkg.com/bootstrap-vue#2.21.2/dist/bootstrap-vue.css" rel="stylesheet" />
<script src="https://unpkg.com/vue#2.6.12/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue#2.21.2/dist/bootstrap-vue.js"></script>
<div id="app">
<b-btn v-b-modal.my-modal>Open Modal</b-btn>
<b-modal id="my-modal" #close="onClose">
Click the `X` top right to see an alert.
</b-modal>
</div>

How can i close the vue popover when i scroll the screen

I haven't decided any popover for Vue.
Device is Touch devices
For touch devices I need click event for opening of popover.
Scenario:
I used Vue bootstrap popover or tooltip
it is stuck to the screen when I am scrolling.
I need to remove when scrolling
You can use this snippet:
new Vue({
el: "#app",
methods: {
do_sth() {
this.$root.$emit('bv::hide::popover')
}
},
created () {
window.addEventListener('scroll', this.do_sth);
},
});
body .wrapper {
padding: 100px 20px;
min-height: 2000px;
}
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap#4.5.3/dist/css/bootstrap.min.css" />
<script src="https://unpkg.com/vue#2.6.12/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue#2.21.2/dist/bootstrap-vue.min.js"></script>
<div id="app">
<div class="wrapper">
<b-button
href="#"
tabindex="0"
v-b-popover.click="'Popover content'"
title="Popover title"
>
Link button with popover directive
</b-button>
</div>
</div>

How to disable collapse v-b-toggle event on input?

So I have a v-b-toggle, that toggles other div. Everything works fine, but into the div, where v-b-toggle is, i have input-checkbox. The problem is, that if you click on this checkbox, toggle also works(open div and then close it instantly). Is there any possibility to disable toggle event on this particular input?
code:
<div class="box-header" v-b-toggle="$id(`collapse-${i}`)"><input type="checkbox"></div>
You can add #click.stop to your input, which will stop click events from propagating.
The stop modifier is a helper for stopPropagation
You can also read more about vue event modifiers on the vue docs.
new Vue({
el: '#app'
})
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-vue/2.18.1/bootstrap-vue.min.css" />
<script src="//cdn.jsdelivr.net/npm/vue#2.6.12/dist/vue.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-vue/2.18.1/bootstrap-vue.min.js"></script>
<div id="app">
<div v-b-toggle.my-collapse>
Some text
<input type="checkbox" #click.stop/>
</div>
<b-collapse id="my-collapse">
Hello<br />
World
</b-collapse>
</div>

Tooltip for mobile screen

Is it allowed if tooltip is not having an href component?
Here is my code :
<a data-toggle="tooltip" title="Please click on map of your precise location"><i class="fi flaticon-question"></i></a>
I removed the href because if I click on the tooltip, the web goes to top of the page (on mobile screen). Is there any other best practice for this?
Does it have to be an anchor at all? You should be able to just do something along the lines of.
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip()
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<i class="glyphicon glyphicon-question-sign"
data-toggle="tooltip"
data-placement="bottom"
title="Contextual help for mouse/touch users">
</i>
<span class="sr-only">Contextual Help for Screen Readers</span>
Unless you're help icon should go somewhere it probably shouldn't be an anchor. The only thing I've added is the sr-only block which will allow screen readers to read out your contextual help.
Alternatively you can make sure that the anchor doesn't move the page by attaching an event to it and preventing the default behaviour.
//untested!
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
//comment the following line out to see page move on click
$('a[data-toggle="tooltip"]').click(function(e){e.preventDefault()})
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<br/><br/><br/><br/>Your icon is below here to show the lack of scrolling<br/><br/><br/><br/><br/><br/><br/>Keep going...<br/><br/><br/><br/><br/><br/><br/><br/><br/>Just a little more<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<a href="#" data-toggle="tooltip"
title="Please click on map of your precise location">
<i class="glyphicon glyphicon-question-sign"></i>
</a>

html5videoplayer - control bar - missing or double display

I'm using html5videoplayer 6.2.14 in a typo3 6.1.7 installation. The control bar doesn't appear as it should - either missing or double display (because the mouseover text like "play" appears with the image, mouseover text doesn't show up).
The plugin parameters are set to autoplay and show control bar.
http://www.alexianer-berlin-hedwigkliniken.de/index.php?id=5674
How can I correct this?
This is the code without control bar:
<div id="video_4" class="video-js vjs-default-skin vjs-paused" width="680" height="385" style="width: 680px; height: 385px;">
<video id="video_4_html5_api" class="vjs-tech" data-setup="{"techOrder":["youtube","vimeo","html5","flash"], "ytcontrols": true}" autoplay="" preload="auto">
</video>
</div>
And that's the code with double control bar:
<video id="video_4_html5_api" class="vjs-tech" data-setup="{"techOrder":["youtube","vimeo","html5","flash"], "ytcontrols": true}" autoplay="" preload="auto" src="....webm">
<div class="vjs-control-bar">
<div class="vjs-play-control vjs-control vjs-playing" role="button" aria-live="polite" tabindex="0">
<div class="vjs-control-content">
<span class="vjs-control-text">Pause</span>
</div>
</div>
</div>
Thanks for any help!
You're loading two different versions of video.js's javascript and css, and they're conflicting.
v4.9.0:
<link href="typo3conf/ext/html5videoplayer/Resources/Public/video-js-4.9.0/video-js.min.css" type="text/css" rel="stylesheet" media="screen" />
<script src="typo3conf/ext/html5videoplayer/Resources/Public/video-js-4.9.0/video.js" type="text/javascript"></script>
v3.2.0:
<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/c/video.js"></script>
You should remove the old version.