UnverseJS
Summary: Information about how different Unverse plugins can coexist
This category contains recipes using the Unverse JavaScript library.
The current release 10.02 may not work well if it is called more than once, and the docReady() function will not work multiple times. For this reason, developers of plugins built with Unverse need to coordinate in order to coexist.
First, include the unverse.js script with your recipe.
Second, to make sure the skin includes unverse.js only once, we use the same key for the HTML headers. In your-recipe.php use this snippet:
SDVA($HTMLHeaderFmt
, array('unverse.js' => "<script type='text/javascript' src='$FarmPubDirUrl
/yourdir/unverse.js'></script>\n"));
The '
part is the path to your unverse.js file. $FarmPubDirUrl
/yourdir/unverse.js' SDVA()
makes sure that only the first plugin will include it.
Third, in order to run multiple functions on page load, use the following snippet at the beginning of your JavaScript file:
if (typeof _.dRF == 'undefined') _.dRF = []; // init docReadyFunctions function docReady(){ for(var i=0; i<_.dRF.length; i++) _.dRF[i](); } // run them
This snippet instructs Unverse to run all functions contained in the _.dRF[] array. That means that we can add our functions to this array without destroying previously defined functions.
Fourth, we add our own functions to the _.dRF[] array:
_.dRF.push(function(){ // new docReadyFunction // here my code run on startup. });
If you have any questions, contact me (Petko).
Information about how different Unverse plugins can coexist
- Cookbook /
- DragDropMultiUpload Allow authors to upload files by simply dropping them into the wiki page (Beta)
- I19 Translator-oriented edit form, easing the internationalization (i18n) of a wiki (Experimental)
- Mini Simple, lightweight, un-bloated gallery with thumbnail generator
- MiniEdit An easy to use visual editor for Mini galleries (experimental)