I have found a MooTools version of Nivoo Slider that (in theory) will work with our MooTools dropdown menu. However, the menu is using MooTools 1.2.x, and Nivoo is using 1.3.2 or 1.4.0. Every time I try and use both the menu and the slider, the menu stops working.
Are the versions of the MooTools framework not backward compatible?
Also, are these plugins compatible or is one overriding the other?
I don't know enough about JS to correct my errors or rewrite the function call. Is there a good beginner's tutorial for this?
window.addEvent('domready', function () {
var menu = new UvumiDropdown('dropdown-demo');
// initialize Nivoo-Slider
new NivooSlider($('slider'), {
directionNavHide: true,
effect: 'wipeDown',
interval: 1000
});
});
In trying to convert without compatibility, here are instructions that I was not sure how to implement.
Instruction
:: Line of 1.2 code
$clear => use the native clearTimeout when using fn.delay, use clearInterval when using fn.periodical.
:: $clear(a.retrieve('closeDelay'))
myFn.create => Use the according functions like .pass, .bind, .delay, .periodical
:: this.createSubmenu(this.menu)
myFn.bind(this, [arg1, arg2, arg3]) => myFn.bind(this, arg1, arg2, arg3) OR myFn.pass([arg1, arg2, arg3], this)
:: this.domReady.bind(this)
$$ now only accepts a single selector, an array or arguments of elements
:: $$(b,b.getChildren('li')
These instructions are with compatibility. I'm trying both.
myElement.get('tween', options); // WRONG
myElement.set('tween', options).get('tween'); // YES, INDEED.
:: this.menu.get('tag')!='ul'
:: this.menu.getElement('ul')
OK I tested the UvumiDropdown latest build with mootools 1.4.x and it worked fine as long as I included a Mootools more build that includes Fx.Elements
Hope this helps
MooTools follows SemVer (Semantic Versioning), meaning that a minor version number (x.Y.z) bump is not guaranteed to be backward-compatible (and is usually not).
However, new versions come with a compatibility layer. Just tick the box on the MooTools Core builder if you really can't upgrade your code. You should though avoid to do such a thing, it is bad for performance and potentially forward-compatibility.
As for a tutorial, the best way to learn how to upgrade code from one version to the other is to read the changelog of the 1.3 to learn about the differences with 1.2, and from the 1.3 to the 1.4 if you want to upgrade to the latest version. From this knowledge, rewrite all calls that make use of outdated APIs.
It looks like a daunting task at first, but it usually goes very quickly (actually, in this precise case, it is most often about rewriting
Hash
references and.each
calls). It might be hard if you're learning JS, but it will definitely be a very rewarding experience in JS, and especially in MooTools, as you'll learn about what makes a code ”Mooish” :)