-
Mootools Tips in C3
I want to move certain tips to other positions, unfortunately Contao assigns a default script to ALL a links. Is there a way in a custom mootools script to then detach the tips from your selectors and then reinitialise it with your selectors using different parameters.
The code below is trying to move the tips for the main BE navigation, but it doesn't work. Probably because the Tips is already initialised for those a links. Since Contao doesn't store a variable name to the tips, I can't retrieve that by variable to execute the detach() method.
Code:
$$('#tl_navigation li a').each(function(el) {
new Tips.Contao(el, {
offset: {x:100, y:100}
});
});
-
Re: Mootools Tips in C3
Why don't you overwrite Backend function in your file and include it after the default BE core.js
Code:
Backend.addInteractiveHelp = function()
{
new Tips.Contao('p.tl_tip', {
offset: {x:9, y:21},
text: function(e) {
return e.get('html');
}
});
// Links and input elements
['a[title]', 'input[title]'].each(function(el) {
new Tips.Contao($$(el).filter(function(i) {
return i.title != '';
}), {
offset: {x:0, y:26},
// Add your logic here
onShow: function(tip, el){
el.setStyles({
color: 'red'
})
}
});
});
// Images
$$('img[title]').filter(function(i) {
return i.title != '';
}).each(function(el) {
new Tips.Contao(el, {
offset: {x:0, y:((el.get('class') == 'gimage') ? 60 : 30)}
});
});
}
-
Re: Mootools Tips in C3
I never even thought about that. I guess you can. Let me give it a try. I just hate breaking the standard system, just to add a small feature, then whenever leo changes that code, I have to keep updating mine too.
-
Re: Mootools Tips in C3
thanks for the "tip" tsarma. :lol:
I did it by creating a unique tip instance with it's own parameters before the standard one. I was trying to remove/detach or undo the tips, but without that variable name (which isn't used in the init), you can't do anything. The first one, hides the tip and the second one moves the offset to a different position.
Code:
Backend.addInteractiveHelp = function()
{
new Tips.Contao('p.tl_tip', {
offset: {x:9, y:21},
text: function(e) {
return e.get('html');
}
});
$$('#tl_navigation li.tl_level_1_group > a').each(function(el) {
new Tips.Contao(el, {
onShow: function(tip,el) { tip.hide();}
});
});
$$('#tl_navigation ul.tl_level_2 li a').each(function(el) {
new Tips.Contao(el, {
offset: {x:0, y:80}
});
});
// Links and input elements
['a[title]', 'input[title]'].each(function(el) {
new Tips.Contao($$(el).filter(function(i) {
return i.title != '';
}), {
offset: {x:0, y:26}
});
});
// Images
$$('img[title]').filter(function(i) {
return i.title != '';
}).each(function(el) {
new Tips.Contao(el, {
offset: {x:0, y:((el.get('class') == 'gimage') ? 60 : 30)}
});
});
}