ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: scripple on March 29, 2014, 10:44:37 am

Title: News Fader Quirks
Post by: scripple on March 29, 2014, 10:44:37 am
A few quirks regarding the news fader.

1) I only have one news item and the fader decides to fade in and out showing the same item over and over.  The fader should probably not do anything if there are 0 or 1 news items.

2) I don't actually have the fader turned on, I have the theme set to random.  But if I use the header up shrink button when I unshrink the header the javascript starts the fader even though the theme is set not to use it.
Title: Re: News Fader Quirks
Post by: emanuele on March 31, 2014, 04:53:24 pm
They seem to be related, this should fix both:
https://github.com/emanuele45/Dialogo/commit/0f280fb4e5b47278985387c8ba5d622ad38fe90d
Title: Re: News Fader Quirks
Post by: NetFlag on June 03, 2014, 02:21:26 pm
I think there is a Codeline missing in index.template.php
Add:
Code: [Select]
if ($settings['enable_news'] == 2 && empty($context['minmax_preferences']['upshrink']))
above:
Code: [Select]
	addInlineJavascript('
$(\'#elkFadeScroller\').Elk_NewsFader();', true);
Title: Re: News Fader Quirks
Post by: emanuele on June 03, 2014, 02:35:06 pm
Yeah, I know it's a kind of trick what I did there... O:-)
The problem adding that if is that the moment you expand the header, the news fader would not be initialized. So I'd have to add the initialization on the "expand" action, but then it could be tricky if you expand and collapse and expand again, because the news fader would be initialized multiple times on the same item, etc.
It's a kind of trade-off...

Of course this comes with the usual disclaimer: I hate javascript, so I may be terribly wrong. :P
Title: Re: News Fader Quirks
Post by: NetFlag on June 03, 2014, 02:54:41 pm
/me

I divined its a little more complicated.
Title: Re: News Fader Quirks
Post by: emanuele on June 03, 2014, 05:49:04 pm
lol

/me is able to make things complicated at will! :P

Actually... sorry, today I'm a bit slow (it's the truth, my brain didn't wake up this morning), and now that I re-read your message I feel I understood it wrong. I'll check again tomorrow. lol

...heck, didn't I remove moderators from the linktree a while ago? Why they are still popping around? (Reminder: Display has (still) moderators in the linktree.)
Title: Re: News Fader Quirks
Post by: scripple on June 27, 2014, 10:04:06 pm
So this seems to be alive again in RC1.  My one and only one news item is fading in and out even though there is nothing to cycle between.  This is on _light.
Title: Re: News Fader Quirks
Post by: emanuele on June 28, 2014, 03:10:29 am
ARG!
Sorry, my fault...

Try this: in elk_jquery_plugins.js, at the very end, replace the entire plugin with:
Code: [Select]
;(function($) {
$.fn.Elk_NewsFader = function(options) {
var settings = {
'iFadeDelay': 5000,
'iFadeSpeed': 1000
},
iFadeIndex = 0,
$news = $(this).find('li');

if ($news.lenght > 1)
{
$.extend(settings, options);
$news.each(function() {
$(this).fadeOut();
});
$news.eq(0).fadeIn(settings.iFadeSpeed);

setInterval(function() {
$($news[iFadeIndex]).fadeOut(settings.iFadeSpeed, function() {
iFadeIndex++;

if (iFadeIndex == $news.length)
iFadeIndex = 0;

$($news[iFadeIndex]).fadeIn(settings.iFadeSpeed);
});
}, settings.iFadeSpeed + settings.iFadeDelay);
}

return this;
};
})(jQuery);
Title: Re: News Fader Quirks
Post by: scripple on June 28, 2014, 11:57:53 am
Seems to work with a single news item showing solid.  Not tested with multiple items.
Title: Re: News Fader Quirks
Post by: emanuele on June 28, 2014, 02:42:19 pm
Ooops was buggy because of a typo on "length". :-[