TippyJS: Rendering a tippy with "interactive" set makes it (almost) invisble - popover

I wanted to create a Tippy with a button in it:
let tippyActions = function() {
var tippys = document.querySelectorAll('*[id^="tippy"]');
tippys.forEach(tpy => tippy(tpy, {content: tippyContent(tpy),
placement: "left",
trigger: 'click',
allowHTML: true,
hideOnClick: false,
interactive: true,
//zIndex: 99999,}))
}
let tippyContent = function ( tpy) {
let buttonsDiv = document.createElement("div")
let btn1 = document.createElement("a")
btn1.href = `/go/${tpy.url}`
buttonsDiv.appendChild(btn1);
return buttonsDiv.innerHTML;
}
But as soon as I set the interactive flag to true the tippys body disappears:
After reading a bit I first thought I have a zIndex problem, but that apparently was not it.

Turns out that I missed to read a part of the FAQ section in the documentary, where it states that adding appendTo: document.body can solve the problem, which it did in my case:
let tippyActions = function() {
var tippys = document.querySelectorAll('*[id^="tippy"]');
tippys.forEach(tpy => tippy(tpy, {content: tippyContent(tpy),
placement: "left",
trigger: 'click',
allowHTML: true,
hideOnClick: false,
appendTo: document.body, // <---
interactive: true}))
}

Related

How to make AOS not working with Slick slider?

I am using AOS to show html elements on scroll. It works well alone, but when I use it on the pages that contains Slick slider, the elements on which is AOS applied are not showing. Elements are hidden and if there is a lot scroll, it looks like the browser gives wrong information to AOS about current scrolling position and some elements are shown latter.
There is no specific code that makes this problems, any usage of slick on the same page with AOS makes AOS not working.
Did anyone solved this problem, I saw some pending questions on other websites and didn't find any solution?
You have to initiate Aos after the slider is initiate.
I think you have to take in account all the previous sliders.
// On init event
$('#productsCarousel').on('init', function(event, slick){
console.log('#productsCarousel init');
AOS.init({
easing: 'ease-out-back',
duration: 1000
});
});
$('#productsCarousel').slick({
centerMode: true,
centerPadding: '8%',
prevArrow: '<span class="slick-prev slick-btn"><span class="p-3"><span class="icon-prev"></span></span></span>',
nextArrow: '<span class="slick-next slick-btn"><span class="p-3"><span class="icon-next"></span></span></span>',
slidesToShow: 4,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToShow: 1
}
}
]
});
In my case, I put AOS refresh after slick initializations
$(window).on('load', function() {
AOS.init({
duration: 600,
once: true
});
$('.section-product-container').slick({
dots: true,
infinite: true,
slidesToShow: 3,
slidesToScroll: 3,
});
$('.slide-container').slick({
dots: true,
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
speed: 300,
autoplay: true,
fade: true,
cssEase: 'linear',
customPaging : function(slider, i) {
var number = (i+1);
if ((i+1) < 10)
number = '0'+(i+1);
return '<a>'+ number +'</a>';
}
});
$('.section-customer-container').slick({
dots: true,
infinite: true,
slidesToShow: 5,
slidesToScroll: 5,
customPaging : function(slider, i) {
if ((i+1) < 10)
return '<a>0'+(i+1)+'</a>';
return '<a>'+ i +'</a>';
}
});
AOS.refresh();
});
$(document).ready(function () {
$('#hero-slider').on('init', function (e, slick) {
var$firstAnimatingElements = $('div.hero-slide:first-child').find('[data-animation]');
doAnimations($firstAnimatingElements);
});
$('#hero-slider').on('beforeChange', function (e, slick, currentSlide, nextSlide) {
var$animatingElements = $('div.hero-slide[data-slick-index="' + nextSlide + '"]').find('[data-animation]');
doAnimations($animatingElements);
});
$('#hero-slider').slick({
// autoplay: true,
// autoplaySpeed: 10000,
dots: true,
fade: true
});
functiondoAnimations(elements) {
varanimationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
elements.each(function () {
var$this = $(this);
var$animationDelay = $this.data('delay');
var$animationType = 'animated ' + $this.data('animation');
$this.css({
'animation-delay': $animationDelay,
'-webkit-animation-delay': $animationDelay
});
$this.addClass($animationType).one(animationEndEvents, function () {
$this.removeClass($animationType);
});
});
}
});
I finally found solution for this problem.
I managed to make animation work on first slide, but it didn't work on other slides, so I used slick events beforeChange and afterChange. In the first I removed, and in second I added the "aos-animate" class. I tried with AOS.refresh() and AOS.refreshHard() but it didn't help
This is my solution
$('#homeslider')
.on('beforeChange', function() {
$('.slider_title').removeClass("aos-animate");
$('.slider_subtitle').removeClass("aos-animate");
$('.small_cta').removeClass("aos-animate");
$('.big_cta').removeClass("aos-animate");
// AOS.refreshHard(); this didn't work
})
.on('afterChange', function(event, slick, currentSlide) {
$('.slider_title').addClass("aos-animate");
$('.slider_subtitle').addClass("aos-animate");
$('.small_cta').addClass("aos-animate");
$('.big_cta').addClass("aos-animate");
// AOS.refreshHard(); this didn't work
});
These classes are a part of each slide and each of them has class like this
<div class="slider_title" data-aos="zoom-in" data-aos-delay="300"></div>
And one more thing, I added AOS.init(); after slick initialization

Fullcalendar eventOverlap issue

I use fullCalendar 2.6 and I only want one allday event per day.
I use this :
eventOverlap: false
It works if I put an event and move it on a day which has already an event : they won't overlap.
But if I click on a day which has already an event, it overlaps and I get 2 events (or more) at the same date...
I use this too on my select function :
overlap: false
which does not do the trick..
What can I do ? any idea ?
And another issue is when I use ajax to send start/end dates, it only works when I click to add an event but not when I move it using arrows when I put my cursor on the edge of the event to change its size...
My code :
function renderCalendar() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay',
},
defaultDate: dateNow,
defaultView: 'month',
lang: 'fr',
height: 'auto',
editable: true,
allDaySlot: true,
weekNumbers: false,
timeFormat: 'H:mm',
slotEventOverlap: false,
weekends: true,
selectable: true,
selectHelper: true,
eventOverlap: false,
select: function(start, end) {
var title = 'Occupé';
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end,
allDay: true,
overlap: false,
color: '#bf0000',
textColor: '#ffffff',
};
$('#calendar').fullCalendar('renderEvent', eventData, true);
}
$('#calendar').fullCalendar('unselect');
alert(start);
alert(end);
}
});
Thanks for your help !
well.. selectOverlap set to "false" is the solution :)
for the second problem, the solution must be eventResizeStop but I didn't find it yet
Try this.
select: function(start, end) {
var title = 'Occupé';
var eventData;
var sameDayEvents = $('#calendar').fullCalendar( 'clientEvents' ,function(event) {
if (event.start.format('YYYY-mm-dd') == start.format('YYYY-mm-dd')) {
return true;
} else {
return false;
}
});
if (!sameDayEvents.length && title) {
eventData = {
title: title,
start: start,
end: end,
allDay: true,
overlap: false,
color: '#bf0000',
textColor: '#ffffff',
};
$('#calendar').fullCalendar('renderEvent', eventData, true);
}
$('#calendar').fullCalendar('unselect');
alert(start);
alert(end);
}

BUG? CKeditor adds space begin P tag

I use CKEditor in rtl mode and when I write something in this, I see some space in output like this image:
How can prevent this spaces?
My code:
var Editor1 = CKEDITOR.replace('editor', {
toolbar: 'Basic',
instanceReady: function (ev) {
this.dataProcessor.writer.setRules('p',
{
indent: false,
breakBeforeOpen: true,
breakAfterOpen: false,
breakBeforeClose: false,
breakAfterClose: true
});
}

Extjs4 drag and drop zones error with IE,FF and Safari

I have multiple grids in a panel. The base grids have data in them and can be dragged and dropped between each other. All the grids in the panel should be able to drag and drop between each other. This works perfectly in chrome but not Firefox, IE, or Safari.
In IE,FF and Safari the grids with data in them will drag and drop between each other w/o problem. They will not between the empty grids. I tried adding data to the empty grids but that wasn't the problem. Firebug also errors when using it with Extjs so any bugs i get are from a different dev tool. I have reinstalled all of those browsers and that is not the answer either. Im stuck...
edit I found out in chrome the viewconfig for my dragdrop groups are set but it doesnt set in the other browsers
This is my base grid with data in it.
var rround = "panel-game-"+round;
var ss = Ext.create('Ext.grid.Panel', {
stateful: true,
id: "panel-game-"+round,
stateId: 'stateGrid',
autoScroll: false,
store: store,
columns: [
{
text : 'Teams',
flex : 1,
sortable : true,
dataIndex: 'team_name'
}
],
height: 100,
width: 150,
title: 'Game ' + round,
viewConfig: {
stripeRows: true,
plugins: {
ptype: 'gridviewdragdrop',
dragGroup: [groups],
dropGroup: [groups]
},
listeners: {
drop: function(node, data, dropRec, dropPosition,record,store) {
var dropOn = dropRec ? ' ' + dropPosition + ' ' + dropRec.get('name') : ' on empty view';
var data = this.store.data.items;
var sdata = new Array();
data.each(function(e){
var bleh = {team_id: e.data.team_id, team_name:e.data.team_name};
sdata.push(bleh);
})
removeDupe(sdata,this.store);
}
}
}
});
This is my empty grid that should accept drops and should also drag when there is data in it.
var rCell = Ext.create('Ext.grid.Panel', {
stateful: true,
id: "panel-game-"+i+'-'+a,
stateId: 'stateGrid',
autoScroll: false,
store: rCellStore,
columns: [
{
text : 'Teams',
flex : 1,
sortable : true,
dataIndex: 'team_name'
}
],
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop',
dragGroup: [groups],
dropGroup: [groups]
},
listeners: {
beforedrop: function(node,data,overModel,dropPosition,eOpts){
console.log(node);
},
drop: function(node, data, dropRec, dropPosition, record) {
console.log("drop");
var dropOn = dropRec ? ' ' + dropPosition + ' ' + dropRec.get('title') : ' on empty view';
var f = node.id.replace('-body','');
var newval = data.records[0].data;
if(f != undefined && f != ''){
var fstore = Ext.getCmp(f).getStore();
fstore.add(newval);
}
var data = this.store.data.items;
var sdata = new Array();
data.each(function(e){
var bleh = {team_id: e.data.team_id, team_name:e.data.team_name};
sdata.push(bleh);
})
removeDupe(sdata,this.store);
}
}
},
height: 100,
width: 150,
title: 'Game ',
viewConfig: {
stripeRows: true
}
});
It does not give a dropzone avaliable when i and trying to drag something over. It could be that but im not sure how to fix it.
The problem was the second viewConfig{stripeRows:true}. Chrome could figure it out but the other browsers were overwriting the first viewConfig with the second.

In Sencha Touch 2 binding data to tpl with Panel not working

I am new to Sencha Touch and trying Sencha Touch version 2 for a demo of xtemplates. This is what I have code.
Ext.application({
name: 'Templates',
launch: function(){
var content, planetInfo, planetEarth;
planetEarth = { name: "Earth", mass: 1.00 };
planetInfo = new Ext.XTemplate(
"<h2>{name}</h2>mass: {mass}"
);
content = new Ext.Panel({
fullscreen: true,
scroll: 'vertical',
tpl: planetInfo
});
content.update(planetEarth);
}
});
output for this code should be in HTML format in the panel. But I just get [object Object]. Please help.
Don't use content.update(planetEarth) method, because it is deprecated in sencha-touch-2.
Here is an example of the correct code:
Ext.application({
name: 'Templates',
launch: function() {
var content, planetInfo, planetEarth;
planetEarth = { name: "Earth", mass: 1.00 };
planetInfo = new Ext.XTemplate(
"<h2>{name}</h2>mass: {mass}"
);
content = Ext.create("Ext.Panel", {
fullscreen: true,
scroll: 'vertical',
tpl: planetInfo,
data: planetEarth
});
}
});
To update display values (Sencha Touch 2), use "setRecord(with new model instance)".
me.getSomeComponentWithTpl().setRecord(someModelInstance);

Resources