1/*!
2 *
3 * Based on
4 * liScroll 1.0
5 * Examples and documentation at:
6 * http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
7 * 2007-2010 Gian Carlo Mingati
8 * Version: 1.0.2.1 (22-APRIL-2011)
9 * Dual licensed under the MIT and GPL licenses:
10 * http://www.opensource.org/licenses/mit-license.php
11 * http://www.gnu.org/licenses/gpl.html
12 * Requires:
13 * jQuery v1.2.x or later
14 *
15 * Extended to read config options from DokuWiki by M.Bohn mjbohn@gmail.com
16 */
17
18
19jQuery.fn.liScroll = function(settings) {
20    settings = jQuery.extend({
21        travelocity: JSINFO['plugin_scrollticker']['speed'] / 100
22    }, settings);
23
24    return this.each(function(){
25        var $strip = jQuery(this);
26        $strip.addClass("newsticker"); // each ul inside <scrollticker> gets class added
27        var stripWidth = 1;
28        var separator = JSINFO['plugin_scrollticker']['separator'];
29        separator = separator.replace(/\s/g, '\xa0'); //make spaces safe
30
31        $strip.find("li").each(function(i){ //iterate through every <li>
32            var liTxt = jQuery( this ).html();
33            if(i < $strip.find("li").length -1) {
34                jQuery(this).html(liTxt + separator); // add separator between items
35            }
36            else{
37                jQuery(this).html(liTxt );
38            }
39
40            // add counter if desired
41            jQuery( this ).addClass("counter_" + JSINFO['plugin_scrollticker']['counterstyle']);
42
43            //sum up width of ticker items including separator
44            stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar and Fabien Volpi
45        });
46
47        var $mask = $strip.wrap("<div class='mask'></div>");
48        var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");
49        var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width
50
51        // enlarge strip to fit counter
52        if(JSINFO['plugin_scrollticker']['counterstyle'] != 'none')
53        {
54            stripWidth += 21 * $strip.find('li').length; // why the hell 21 ??
55        }
56
57
58        $strip.width(stripWidth);
59
60        var totalTravel = stripWidth+containerWidth;
61        var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye
62        function scrollnews(spazio, tempo){
63            $strip.animate({left: '-='+ spazio}, tempo, "linear", function(){
64                $strip.css("left", containerWidth);
65                scrollnews(totalTravel, defTiming);
66            });
67        }
68        scrollnews(totalTravel, defTiming);
69        $strip.hover(function(){
70                if(JSINFO['plugin_scrollticker']['stopOnHover']){jQuery(this).stop();}
71            },
72            function(){
73                var offset = jQuery(this).offset();
74                var residualSpace = offset.left + stripWidth;
75                var residualTime = residualSpace/settings.travelocity;
76                scrollnews(residualSpace, residualTime);
77            });
78    });
79};
80
81
82jQuery(function(){
83    jQuery("div.ui-newsticker ul").liScroll({
84
85    });
86    var $ticker = jQuery(".tickercontainer");
87
88    $ticker.css("border-radius",JSINFO['plugin_scrollticker']['border-radius']);
89
90    if(JSINFO['plugin_scrollticker']['showBorder']){
91        $ticker.css("border",JSINFO['plugin_scrollticker']['border']);
92    }
93
94    $ticker.css("width",JSINFO['plugin_scrollticker']['width']);
95    $ticker.css("height",JSINFO['plugin_scrollticker']['height']);
96    $ticker.css("color",JSINFO['plugin_scrollticker']['textcolor']);
97    jQuery(".tickercontainer ul li").css("color",JSINFO['plugin_scrollticker']['textcolor']);
98    $ticker.css("background-color",JSINFO['plugin_scrollticker']['bgcolor']);
99    jQuery(".tickercontainer ul li").css("background-color","transparent");
100});
101