SimplePortal

Support => International Support => Portuguese => Topic started by: Costa on August 03, 2009, 12:15:05 AM

Title: [Bloco] Notícias com fade
Post by: Costa on August 03, 2009, 12:15:05 AM
Abra um bloco php e coloque.

Code: (SMF 1.1.X) [Select]
   global $context, $settings;

   echo '
                        <div id="sp_news_fader_', $id, '" class="sp_center sp_fullwidth"><b>', $context['news_lines'][0], '</b></div>
                        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                           // The fading delay (in ms.)
                           var smfFadeDelay = ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], ';
                           // Fade from... what text color? To which background color?
                           var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
                           // Surround each item with... anything special?
                           var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

                           var foreColor, backEl, backColor;

                           if (typeof(document.getElementById(\'sp_news_fader_', $id, '\').currentStyle) != "undefined")
                           {
                              foreColor = document.getElementById(\'sp_news_fader_', $id, '\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
                              smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

                              backEl = document.getElementById(\'sp_news_fader_', $id, '\');
                              while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
                                 backEl = backEl.parentNode;

                              backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
                              smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
                           }
                           else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
                           {
                              foreColor = document.defaultView.getComputedStyle(document.getElementById(\'sp_news_fader_', $id, '\'), null).color.match(/rgb\((\d+), (\d+), (\d+)\)/);
                              smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

                              backEl = document.getElementById(\'sp_news_fader_', $id, '\');
                              while (document.defaultView.getComputedStyle(backEl, null).backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
                                 backEl = backEl.parentNode;

                              backColor = document.defaultView.getComputedStyle(backEl, null).backgroundColor.match(/rgb\((\d+), (\d+), (\d+)\)/);
                              smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
                           }

                           // List all the lines of the news for display.
                           var smfFadeContent = new Array(
                              "', implode('",
                              "', $context['fader_news_lines']), '"
                           );
                        // ]]></script>
                        <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/fader.js"></script>
                        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                           smfFadeScroller = document.getElementById(\'sp_news_fader_', $id, '\');
                        // ]]></script>';


Code: (SMF 2.0 RC1.2) [Select]
   global $context, $settings;

   echo '
                        <div id="smfNewsFader"><div id="smfFadeScroller" class="sp_center sp_fullwidth"><span>', $context['news_lines'][0], '</span></div></div>
                  <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
                     // The fading delay (in ms.)
                     var smfFadeDelay = ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], ';
                     // Fade from... what text color? To which background color?
                     var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 255, "g": 255, "b": 255};
                     // Surround each item with... anything special?
                     var smfFadeBefore = "<b>", smfFadeAfter = "</b>";

                     var foreColor, foreEl, backEl, backColor;

                     if (typeof(document.getElementById(\'smfFadeScroller\').currentStyle) != "undefined")
                     {
                        foreColor = document.getElementById(\'smfFadeScroller\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
                        smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

                        backEl = document.getElementById(\'smfFadeScroller\');
                        while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
                           backEl = backEl.parentNode;

                        backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
                        smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
                     }
                     else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
                     {

                        foreEl = document.getElementById(\'smfFadeScroller\');

                        while (document.defaultView.getComputedStyle(foreEl, null).getPropertyCSSValue("color") == null && typeof(foreEl.parentNode) != "undefined" && typeof(foreEl.parentNode.tagName) != "undefined")
                           foreEl = foreEl.parentNode;

                        foreColor = document.defaultView.getComputedStyle(foreEl, null).getPropertyValue("color").match(/rgb\((\d+), (\d+), (\d+)\)/);
                        smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};

                        backEl = document.getElementById(\'smfFadeScroller\');

                        while (document.defaultView.getComputedStyle(backEl, null).getPropertyCSSValue("background-color") == null && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
                           backEl = backEl.parentNode;

                        backColor = document.defaultView.getComputedStyle(backEl, null).getPropertyValue("background-color");//.match(/rgb\((\d+), (\d+), (\d+)\)/);
                        smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
                     }

                     // List all the lines of the news for display.
                     var smfFadeContent = new Array(
                        "', implode('",
                        "', $context['fader_news_lines']), '"
                     );
                  // ]]></script>
                  <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/fader.js"></script>';
 

Créditos ao Nathaniel (http://simpleportal.net/index.php?action=profile;u=4)
Title: Re: [Bloco] Notícias com fade
Post by: candidosa2 on August 04, 2009, 07:22:55 AM
Muito bom e Util
SimplePortal 2.3.8 © 2008-2024, SimplePortal