/** * Ticker that scrolls its contents with various speeds and pauses * * @param $fields * An associative array of fields, possibly including: * * "content_fbml" => string * The FBML content of the ticker. The first top-level element * should contain sub-elements, and their sizes determine where * the ticker would pause between automatically scrolling. * The ticker animates by scrolling its inner contents. * * "vertical" => bool * Defaults to true. If false, the ticker scrolls horizontally. * * "speed" => bool * The scrolling speed. * This is the number of items that would scroll by in 1 second, * if there were no pauses. * When the speed is positive, vertical tickers scroll down, and * horizontal tickers scroll to the right. New content seems to come in * from the bottom (for vertical tickers) or right (for horizontal tickers) * as the ticker scrolls. The element inside the ticker will start out * aligned with the top side of the ticker (for vertical tickers), * or the left side of the ticker (for horizontal tickers). * When the speed is negative, all this faces the other way. * * "pause_ms" => int * Defaults to 2000. This is the number of milliseconds to wait * after each second-level element of $content_fbml is automatically * scrolled completely into view. * * "pause_ms_min" => int * If set, then the number of milliseconds to pause is a random * integer between $pause_ms_min and $pause_ms. * * "scrollbars" => bool * Defaults to true. If true, shows scrollbars, otherwise doesn't. * (Note: this will let the user know how much content is left, * and be able to see it before it would automatically scroll into view.) * * "scrollbars_pause_ms" => int * Defaults to 500. The ticker pauses its automatic scrolling when the user * starts using the scrollbars. This is the number of milliseconds to wait * until resuming the automatic scrolling. * * "anim_ms" => int * Defaults to 100. This is the number of milliseconds between calls to * autoScroll. * * "initial_scroll_mode" => int * Defaults to 'auto'. This is the mode that scrolling starts out in. * Possible values are 'auto' and 'paused'. * * "ease" => string * Optional. If set, specifies the name of the ease function */ function pie_tool_ticker($fields = array()) { $defaults = array('vertical' => true, 'speed' => 1, 'pause_ms' => 2000, 'scrollbars' => true, 'scrollbars_pause_ms' => 500, 'anim_ms' => 100); $fields2 = array_merge($defaults, $fields); if (!isset($fields2['pause_ms_min'])) { $fields2['pause_ms_min'] = $fields2['pause_ms']; } if (!isset($fields2['content_fbml'])) { $li_array = array(); for ($i = 0; $i < 1000; ++$i) { $li_array[] = "<li>Missing \$content_fbml parameter. This is just example {$i}...</li>"; } $default_content = implode("\n", $li_array); if ($fields2['vertical']) { $fields2['content_fbml'] = "<ul class='error'>{$default_content}</ul>"; } else { $fields2['content_fbml'] = "<ul class='error'>{$default_content}</ul>"; } } // TODO: develop one for just HTML, // and then check for FBML environment, instead of assuming it. Pie_Response::addScript('plugins/pie/fbjs/Pie.fb.js'); Pie_Response::addScript('plugins/pie/fbjs/Ticker.fb.js'); Pie_Response::addStylesheet('plugins/pie/css/Ticker.css'); $direction_class = $fields2['vertical'] ? 'vertical' : 'horizontal'; $scrollbars_class = $fields2['scrollbars'] ? 'scrollbars' : ''; return Pie_Html::tag('div', array('id' => 'ticker', 'class' => "ticker {$direction_class} {$scrollbars_class}"), $fields2['content_fbml']); }
/** * Returns the HTML markup for referencing all the stylesheets added so far * @param string $between * Optional text to insert between the <link> elements. * @param string $slot_name * Optional. If provided, returns only the stylesheets added while filling this slot. * * @return string the HTML markup for referencing all the stylesheets added so far */ static function stylesheets($between = '', $slot_name = null) { $stylesheets = self::stylesheetsArray($slot_name); if (empty($stylesheets)) { return ''; } $tags = array(); foreach (self::$stylesheets as $stylesheet) { $href = ''; $media = 'screen, print'; $type = 'text/css'; extract($stylesheet, EXTR_IF_EXISTS); //$return .= "<style type='$type' media='$media'>@import '$href';</style>\n"; $tags[] = Pie_Html::tag('link', array('rel' => 'stylesheet', 'type' => $type, 'href' => $href, 'media' => $media)); } return implode($between, $tags); }