moostick dot jsA Mootools-powered, unobtrusive, Javascript news ticker library. /mouthful AboutMoostick will take in any type of li-containing element and turn it into an animated news ticker, fading between each headline at a set interval. VersionHomepageRequirementsCopyrightcopyright © 2007 Stephane Daury: http://stephane.daury.org/ LicenseMIT License http://www.opensource.org- /licenses- /mit-license.php Copyright © 2007 Stephane Daury http://stephane.daury.org/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Summary | A Mootools-powered, unobtrusive, Javascript news ticker library. | | | | (singleton) Utility class containing helper methods that will be helpful in other classes. | | | | Query string helper for the Moostick script (NOT the document that included it). | | Checks if the sent value is an array or convert it. | | (singleton) A multi-list utility wrapper for the Moostick class and processes. | | | | One or more list (ul, ol...) | | | | | | | | Set to true to bypass element validation, for increased rendering speed, but only if you’re absolutely sure about the MstkInit.lists you passed in. | | | | | | Sets the default properties and launches the Moostick modification process if in auto-start mode. | | | | | | | | Modifies the presentation and behaviour of li-containing elements to act as pseudo news tickers, and extends their DOM with itself (eg: myUL.moostick) for easy manipulation. | | | | | | A single list (ul, ol...) | | | | Defines duration for which each headline is displayed including transition time, which can be adjusted through Moostick.fxOptions. | | MooTools effect options for the opacity change used in the transition. | | Set to true to bypass element validation, for increased rendering speed, but only if you’re absolutely sure about the Moostick.list you passed in. | | Set to true to bypass element styles validation, for increased rendering speed, but only if you’re absolutely sure about the Moostick.list you sent. | | | | True if the first time we run. | | | | | | | | MooTools pseudo constructor. | | | | Stops the ticker completely, including the attached mouse events. | | | | | | | | | | | | Sets the mouse events to pause the ticker when the mourse cursor enters the display area. | | Loops through the list’s li elements to set the styles and opacity. | | | | Moostick transition: move first to last, fade new first in then set opacity on new last to 0. | | Handles the MooTools opacity effect, from 0 to 1 |
Procedural code| Safety check | Moostick checks that MooTools is present to avoid errors and prompts to either cancel or be redirected to the MooTools site for more info. | | Auto start mode | Moostick auto-starts by default, unless passed init=0 in the script’s query string for more selective interaction. MstkHelpers must be implemented before this step. |
MstkHelpers(singleton) Utility class containing helper methods that will be helpful in other classes. Notes- Can be used before “ondomready” or “onload” are achieved, and is currently required by the auto-start procedure.
- Can be used directly or have its methods implemented other Classes.
Examplealert(MstkHelpers.qsVar('myKey'));
Summary | | | Query string helper for the Moostick script (NOT the document that included it). | | Checks if the sent value is an array or convert it. |
qsVarQuery string helper for the Moostick script (NOT the document that included it). Takes a query string key, and returns the value, or false if not found. Arguments| key | the key (key=val) to search for, as string. |
Returns| val | the key’s value as string or false if not found. |
checkArray| checkArray: function( | val | ) |
|
Checks if the sent value is an array or convert it. Very useful when you do not know if you are dealing with an single element through $()/$E()/etc or multiple elements through $$()/$E()/etc. ArgumentsReturns| val | the sent value if already an array, or a single-item array. |
MstkInit(singleton) A multi-list utility wrapper for the Moostick class and processes. Notes- Used in auto-start mode to scan the DOM for targeted elements.
- Also supports concept of safe v. fast mode, like <MooStick>.
- When opting to turn off auto-start, it is advised to instantiate the Moostick class directly with a single known list. On the other hand, MstkInit will let you pass multiple ones, such as when dealing with css classes instead of ids, etc.
Example// Enable Moostick on any element with "my-custom-class" css class. MstkInit.go($$('.my-custom-class'), true);
Summary | | | One or more list (ul, ol...) | | | | | | | | Set to true to bypass element validation, for increased rendering speed, but only if you’re absolutely sure about the MstkInit.lists you passed in. | | | | | | Sets the default properties and launches the Moostick modification process if in auto-start mode. | | | | | | |
listsOne or more list (ul, ol...) from $(), $$(), etc. If passed as false, MstkInit will try to search the DOM for list with an id of moostick, or lists with a class of moostick.
autoStartBoolean. Should the constructor launch the DOM modification process, or just set the properties.
trust4SpeedSet to true to bypass element validation, for increased rendering speed, but only if you’re absolutely sure about the MstkInit.lists you passed in.
go| go: function( | lists, | | autoStart, | | interval, | | fxOptions, | | trust4Speed, | | trustOpacity | ) |
|
Sets the default properties and launches the Moostick modification process if in auto-start mode. Arguments
_fastModeAKA the Kamikaze mode. Instantiate a Moostick object for each MstkInit.lists, without any validation, besides making sure we have an array to loop on.
_safeModeAKA the cautious mode. First validates the passed MstkInit.lists or tries to auto-discover targeted DOM elements with “moostick” as an id or class, then calls Moostick for each list.
MoostickModifies the presentation and behaviour of li-containing elements to act as pseudo news tickers, and extends their DOM with itself (eg: myUL.moostick) for easy manipulation. Example: Programming // Auto-discovery mode, looking for li-containing elements with // an id (single) or class of "moostick", then auto-starts. new Moostick(); $('moostick').moostick.stopTick();
// Instantiate Moostick for the "my-custom-id" element. Do // not auto-start. Fade every 5 seconds, for 1/2 second. // Trust the list I sent, but handle the opacity assignment. var myList = new Moostick( $('my-custom-id'), false, 5000, {duration: 500}, true, false ); myList.startTick();
Summary | | | | | A single list (ul, ol...) | | | | Defines duration for which each headline is displayed including transition time, which can be adjusted through Moostick.fxOptions. | | MooTools effect options for the opacity change used in the transition. | | Set to true to bypass element validation, for increased rendering speed, but only if you’re absolutely sure about the Moostick.list you passed in. | | Set to true to bypass element styles validation, for increased rendering speed, but only if you’re absolutely sure about the Moostick.list you sent. | | | | True if the first time we run. | | | | | | | | MooTools pseudo constructor. | | | | Stops the ticker completely, including the attached mouse events. | | | | | | | | | | | | Sets the mouse events to pause the ticker when the mourse cursor enters the display area. | | Loops through the list’s li elements to set the styles and opacity. | | | | Moostick transition: move first to last, fade new first in then set opacity on new last to 0. | | Handles the MooTools opacity effect, from 0 to 1 |
listA single list (ul, ol...) from $(), $E(), etc. This is the element to which Mostick will attach itself. EG: myUL.moostick.stopTick();
autoStartBoolean. Should the constructor launch the DOM modification process, or just set the properties.
intervalDefines duration for which each headline is displayed including transition time, which can be adjusted through Moostick.fxOptions.
trust4SpeedSet to true to bypass element validation, for increased rendering speed, but only if you’re absolutely sure about the Moostick.list you passed in. See also: Moostick.trustOpacity.
trustOpacitySet to true to bypass element styles validation, for increased rendering speed, but only if you’re absolutely sure about the Moostick.list you sent. When ON, we do not loop through each li to set the opacity to 0, therefore assuming you dealt with it in your stylesheets.
_firstRunTrue if the first time we run.
initialize| initialize: function( | list, | | autoStart, | | interval, | | fxOptions, | | trust4Speed, | | trustOpacity | ) |
|
MooTools pseudo constructor. Sets the default properties and launches the Moostick modification process if in auto-start mode. Arguments
stopTickStops the ticker completely, including the attached mouse events. See alsoMoostick.startTick.
_fastModeAKA the Kamikaze mode. Bypasses all element validation.
_safeModeAKA the cautious mode. Validates the passed Moostick.list and tries to apply arbitray default styles before lauching the ticker.
_setMouseEvents| _setMouseEvents: function() |
Sets the mouse events to pause the ticker when the mourse cursor enters the display area. Greatly helps with usability, while still remaining unobstrusive. Uses MooTools’ mouseenter and mouseenter.
_liHandler| _liHandler: function( | styles | ) |
|
Loops through the list’s li elements to set the styles and opacity. Arguments
_runMoostick transition: move first to last, fade new first in then set opacity on new last to 0.
_fadeInHandles the MooTools opacity effect, from 0 to 1 Arguments| item | li element to apply the effect to. |
|