Skip to content

Commit

Permalink
Merge pull request #1 from mjbohn/addconfig
Browse files Browse the repository at this point in the history
Add config options, thx to mjbohn!!
  • Loading branch information
medmen committed Jan 22, 2018
2 parents d1a8629 + 39460cf commit fd4f53d
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 17 deletions.
35 changes: 35 additions & 0 deletions action.php
@@ -0,0 +1,35 @@
<?php
/**
* DokuWiki Plugin scrollticker
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*
* @author Michael Bohn <mjbohn@gmail.com>
*/

if(!defined('DOKU_INC')) die(); // no Dokuwiki, no go

class action_plugin_scrollticker extends DokuWiki_Action_Plugin
{
/**
* Register the handle function in the controller
*
* @param Doku_event_handler $controller The event controller
*/
function register(Doku_Event_Handler $controller)
{
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'addconfig2js');
}


/**
* @param $event
* @param $params
*/
function addconfig2js ($event, $params) {
global $JSINFO;
global $conf;
$this->loadConfig();
$JSINFO['plugin_scrollticker'] = $conf['plugin']['scrollticker'];
}
}
21 changes: 21 additions & 0 deletions conf/default.php
@@ -0,0 +1,21 @@
<?php
/**
* Default settings for the scrollticker plugin
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*
* @author Michael Bohn <mjbohn@gmail.com>
*
*
*/

$conf['counterstyle'] = 'none';
$conf['separator'] = ' +++ ';
$conf['speed'] = 6;
$conf['stopOnHover'] = 1;
$conf['showBorder'] = 0;
$conf['border'] = '0.5px dashed #000';
$conf['border-radius'] = '20px';
$conf['width'] = '90%';
$conf['height'] = '2.5em';
$conf['textcolor'] = 'red';
20 changes: 20 additions & 0 deletions conf/metadata.php
@@ -0,0 +1,20 @@
<?php
/**
* Options for the scrollticker plugin
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*
* @author Michael Bohn <mjbohn@gmail.com>
*
*/

$meta['counterstyle'] = array('multichoice', _choices => array('decimal', 'decimal-leading-zero', 'lower-roman', 'upper-roman','lower-latin', 'upper-latin', 'none'));
$meta['separator'] = array('string');
$meta['speed'] = array('numeric');
$meta['stopOnHover'] = array('onoff');
$meta['showBorder'] = array('onoff');
$meta['border'] = array('string');
$meta['border-radius'] = array('string');
$meta['width'] = array('string');
$meta['height'] = array('string');
$meta['textcolor'] = array('string');
18 changes: 18 additions & 0 deletions lang/en/settings.php
@@ -0,0 +1,18 @@
<?php
/**
* english language file for scrollticker plugin
*
* @author Michael Bohn <mjbohn@gmail.com>
*
*/

$lang['counterstyle'] = 'Add counter in front of ticker items (default none)';
$lang['separator'] = 'Separator between items';
$lang['speed'] = 'Tickerspeed';
$lang['stopOnHover'] = 'Stop Ticker on mouse hover';
$lang['showBorder'] = 'Show border on ticker';
$lang['border'] = 'Border style (default "0.5px dashed #000" )';
$lang['border-radius'] = 'Add rounded corners ( 0 for none )';
$lang['width'] = 'Ticker width (%)';
$lang['height'] = 'Ticker height (default 2em)';
$lang['textcolor'] = 'Color of ticker text';
43 changes: 37 additions & 6 deletions script.js
@@ -1,4 +1,6 @@
/*!
*
* Based on
* liScroll 1.0
* Examples and documentation at:
* http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
Expand All @@ -10,34 +12,53 @@
* Requires:
* jQuery v1.2.x or later
*
* Extended to read config options from DokuWiki by M.Bohn mjbohn@gmail.com
*/


jQuery.fn.liScroll = function(settings) {
settings = jQuery.extend({
travelocity: 0.07
travelocity: JSINFO['plugin_scrollticker']['speed'] / 100
}, settings);
return this.each(function(){
var $strip = jQuery(this);
$strip.addClass("newsticker");
var stripWidth = 1;
var separator = JSINFO['plugin_scrollticker']['separator'];
separator = separator.replace(/\s/g, '\xa0');

$strip.find("li").each(function(i){
var liTxt = jQuery( this ).text();
if(i < $strip.find("li").length -1) {
jQuery(this).text(liTxt + separator);
}
else{
jQuery(this).text(liTxt );
}
stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar and Fabien Volpi

jQuery( this ).addClass("counter_" + JSINFO['plugin_scrollticker']['counterstyle']);

});

// enlarge strip to fit counter
if(JSINFO['plugin_scrollticker']['counterstyle'] != 'none')
{
stripWidth += 21 * $strip.find('li').length;
}

var $mask = $strip.wrap("<div class='mask'></div>");
var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");
var containerWidth = $strip.parent().parent().width(); //a.k.a. 'mask' width
$strip.width(stripWidth);
var totalTravel = stripWidth+containerWidth;
var defTiming = totalTravel/settings.travelocity; // thanks to Scott Waye
function scrollnews(spazio, tempo){
$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){
$strip.css("left", containerWidth);
scrollnews(totalTravel, defTiming);});
$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
}
scrollnews(totalTravel, defTiming);
$strip.hover(function(){
jQuery(this).stop();
if(JSINFO['plugin_scrollticker']['stopOnHover']){jQuery(this).stop();}
},
function(){
var offset = jQuery(this).offset();
Expand All @@ -51,6 +72,16 @@ jQuery.fn.liScroll = function(settings) {

jQuery(function(){
jQuery("div.ui-newsticker ul").liScroll({
// travelocity: 0.15 // the speed of scrolling

});

jQuery(".tickercontainer").css("border-radius",JSINFO['plugin_scrollticker']['border-radius']);

if(JSINFO['plugin_scrollticker']['showBorder']){
jQuery(".tickercontainer").css("border",JSINFO['plugin_scrollticker']['border']);
}

jQuery(".tickercontainer").css("width",JSINFO['plugin_scrollticker']['width']);
jQuery(".tickercontainer").css("height",JSINFO['plugin_scrollticker']['height']);
jQuery(".tickercontainer").css("color",JSINFO['plugin_scrollticker']['textcolor']);
});
48 changes: 37 additions & 11 deletions style.css
@@ -1,10 +1,10 @@
/* liScroll styles */

.tickercontainer { /* the outer div with the black border */
border: 0.1px dashed #000;
border-radius: 20px;
width: 95%;
height: 2em;
/*border: 0.1px dashed #000;*/
/*border-radius: 20px;*/
/*width: 50%;*/
/*height: 2em;*/
margin: 0;
padding: 0;
overflow: hidden;
Expand All @@ -24,7 +24,7 @@ ul.newsticker { /* that's your list */
list-style-type: none;
margin: 0;
padding: 0;
counter-reset: scrollticker-counter;
counter-reset: scrollticker-counter;
}

ul.newsticker li {
Expand All @@ -34,15 +34,41 @@ ul.newsticker li {
background: #fff;
}

ul.newsticker li::before {
content: counter(scrollticker-counter, lower-roman);
counter-increment: scrollticker-counter;
/*ul.newsticker li::before {*/
/*content: counter(scrollticker-counter, lower-roman);*/
/*counter-increment: scrollticker-counter;*/
/*}*/

.counter_upper-roman::before {
content: counter(scrollticker-counter, upper-roman);
counter-increment: scrollticker-counter;
}

.counter_lower-roman::before {
content: counter(scrollticker-counter, lower-roman);
counter-increment: scrollticker-counter;
}

.counter_upper-latin::before {
content: counter(scrollticker-counter, upper-latin);
counter-increment: scrollticker-counter;
}

.counter_lower-latin::before {
content: counter(scrollticker-counter, lower-latin);
counter-increment: scrollticker-counter;
}

.counter_decimal::before {
content: counter(scrollticker-counter, decimal);
counter-increment: scrollticker-counter;
}

ul.newsticker li::after {
content: "\00a0\00a0\00a0 + + + \00a0\00a0\00a0"; /* insert text + + + after each item, add whitspace */
.counter_decimal-leading-zero::before {
content: counter(scrollticker-counter, decimal-leading-zero);
counter-increment: scrollticker-counter;
}

ul.newsticker div {
display: inline;
display: inline;
}
1 change: 1 addition & 0 deletions syntax.php
Expand Up @@ -4,6 +4,7 @@
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author medmen <med-men@gmx.net>
* @author Michael Bohn <mjbohn@gmail.com>
*/

// must be run within Dokuwiki
Expand Down

0 comments on commit fd4f53d

Please sign in to comment.