Skip to content

Commit

Permalink
Initial working commit
Browse files Browse the repository at this point in the history
syntax-plugin detects <scrollticker></scrollticker> tags and expects an unsorted list in there.
This is turned into a scrolling newsticker by adding some css and integrating a jquery-plugin named liScroll (http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html)
This is the first commit working for me - expect everything including bugs, failure, mayhem and a canary singing volbeat songs :)
  • Loading branch information
medmen committed Jan 13, 2017
1 parent 9b2a71f commit ba0b4f2
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
scrollticker Plugin for DokuWiki

format unsorted list as scrolling news ticker

All documentation for this plugin can be found at
https://humanvisualisierungsknecht.de

If you install this plugin manually, make sure it is installed in
lib/plugins/scrollticker/ - if the folder is called different it
will not work!

Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.

----
Copyright (C) medmen <med-men@gmx.net>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

See the COPYING file in your DokuWiki folder for details
7 changes: 7 additions & 0 deletions plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
base scrollticker
author medmen
email med-men@gmx.net
date 2016-12-29
name scrollticker plugin
desc format unsorted list as scrolling news ticker
url https://github.com/medmen/dokuwiki-plugin-scrollticker
56 changes: 56 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*!
* liScroll 1.0
* Examples and documentation at:
* http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
* 2007-2010 Gian Carlo Mingati
* Version: 1.0.2.1 (22-APRIL-2011)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Requires:
* jQuery v1.2.x or later
*
*/


jQuery.fn.liScroll = function(settings) {
settings = jQuery.extend({
travelocity: 0.07
}, settings);
return this.each(function(){
var $strip = jQuery(this);
$strip.addClass("newsticker")
var stripWidth = 1;
$strip.find("li").each(function(i){
stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar and Fabien Volpi
});
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);});
}
scrollnews(totalTravel, defTiming);
$strip.hover(function(){
jQuery(this).stop();
},
function(){
var offset = jQuery(this).offset();
var residualSpace = offset.left + stripWidth;
var residualTime = residualSpace/settings.travelocity;
scrollnews(residualSpace, residualTime);
});
});
};


jQuery(function(){
jQuery("div.ui-newsticker ul").liScroll({
// travelocity: 0.15 // the speed of scrolling
});
});
50 changes: 50 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* liScroll styles */

.tickercontainer { /* the outer div with the black border */
border: 1px solid #000;
background: #fff;
// width: 738px;
width: 100%;
// height: 27px;
margin: 0;
padding: 0;
overflow: hidden;
}

.tickercontainer .mask { /* that serves as a mask. so you get a sort of padding both left and right */
position: relative;
left: 10px;
top: 8px;
width: 718px;
overflow: hidden;
}

ul.newsticker { /* that's your list */
position: relative;
left: 750px;
// font: bold 10px Verdana;
list-style-type: none;
margin: 0;
padding: 0;
}

ul.newsticker li {
float: left; /* important: display inline gives incorrect results when you check for elem's width */
margin: 0;
padding: 0;
background: #fff;
}

/**
ul.newsticker a {
white-space: nowrap;
padding: 0;
color: #ff0000;
font: bold 10px Verdana;
margin: 0 50px 0 0;
}
**/

ul.newsticker span {
margin: 0 10px 0 0;
}
106 changes: 106 additions & 0 deletions syntax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
/**
* DokuWiki Plugin scrollticker (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author medmen <med-men@gmx.net>
*/

// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();

class syntax_plugin_scrollticker extends DokuWiki_Syntax_Plugin {
/**
* @return string Syntax mode type
*/
public function getType() {
// return 'container';
return 'protected';
}

function getAllowedTypes() {
return array('container','substition','protected','disabled','formatting','paragraphs');
}

/**
* @return string Paragraph type
*/
public function getPType() {
return 'block';
}
/**
* @return int Sort order - Low numbers go before high numbers
*/
public function getSort() {
return 201;
}

/**
* Connect lookup pattern to lexer.
*
* @param string $mode Parser mode
*/
public function connectTo($mode) {
$this->Lexer->addEntryPattern('<scrollticker>(?=.*?</scrollticker>)',$mode,'plugin_scrollticker');
//$this->Lexer->addEntryPattern('<scrollticker>',$mode,'plugin_scrollticker');
}

public function postConnect() {
$this->Lexer->addExitPattern('</scrollticker>','plugin_scrollticker');
}


/**
* Handle matches of the scrollticker syntax
*
* @param string $match The match of the syntax
* @param int $state The state of the handler
* @param int $pos The position in the document
* @param Doku_Handler $handler The handler
* @return array Data for the renderer
*/
public function handle($match, $state, $pos, Doku_Handler $handler){
/**
return array($match, $state, $pos, $handler);
switch ($state) {
case DOKU_LEXER_ENTER : return array($state, $match);
case DOKU_LEXER_UNMATCHED : return array($state, $match);
case DOKU_LEXER_EXIT : return array($state, $match);
}
*/
return array($state, $match);
}

/**
* Render xhtml output or metadata
*
* @param string $mode Renderer mode (supported modes: xhtml)
* @param Doku_Renderer $renderer The renderer
* @param array $data The data from the handler() function
* @return bool If rendering was successful.
*/
public function render($mode, Doku_Renderer $renderer, $data) {
if($mode != 'xhtml') return false;
list($state, $match) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
$renderer->doc .= '<div class="ui-newsticker">';
break;
case DOKU_LEXER_UNMATCHED :
$renderer->doc .= $renderer->_xmlEntities($match);
// $renderer->doc .= $match;
break;
case DOKU_LEXER_EXIT :
$renderer->doc .= '</div>';
break;
default:
$renderer->doc.= 'MATCH: '.$renderer->_xmlEntities($match);
$renderer->doc.= 'STATE: '.$renderer->_xmlEntities($state);
}

// $renderer->doc .= var_export($data, true);
return true;
}
}

// vim:ts=4:sw=4:et:

0 comments on commit ba0b4f2

Please sign in to comment.