Using a JavaScript Framework in Vork
Load any mainstream JavaScript library with the $html->jsLoad()
function including: YUI, jQuery, Prototype, MooTools, script.aculo.us, Dojo, SWFObject, Ext Core and Chrome Frame
MooTools example
echo $html->jsLoad('mootools'); //MooTools is now ready to use
echo '<div id="mootools_box">Tweening - powered by MooTools!</div>';
$mootoolsCode = 'var m = 1;
function mootoolsbox() {
var myFx = new Fx.Tween($("mootools_box"));
myFx.start("border", (m++ % 2 ? "10px dotted #ffffff" : "1px dotted #000000"));
}
google.setOnLoadCallback(function() (window.setInterval(mootoolsbox, 1200)));';
echo $html->jsInline($mootoolsCode);
jQuery example
echo $html->jsLoad(array('jquery', 'jqueryui')); //jQuery & jQuery UI are now ready for use
$div = '<div id="draggable-box"><div>You can drag this box by the blue section</div>Powered by jQuery!</div>';
$jQueryCode = 'var jquerybox = function(){
$("#jquery").html("' . addslashes($div) . '");
$("#draggable-box").draggable({"handle": "div"});
}
google.setOnLoadCallback(jquerybox);
echo '<div id="jquery"></div>';
echo $html->jsInline($jQueryCode);
Dojo example
echo $html->jsLoad('dojo'); //Dojo is now ready for use
echo '<div id="dojo_box">This pulsates - powered by Dojo!</div>';
$dojoCode = 'var i = 1;
function dojoFade() {
var animArgs = {node: "dojo_box", duration: 500};
(i++ % 2 ? dojo.fadeIn(animArgs).play() : dojo.fadeOut(animArgs).play());
}
google.setOnLoadCallback(function() (window.setInterval(dojoFade, 1000)));';
echo $html->jsInline($dojoCode);
Using YUI, Prototype, script.aculo.us, SWFObject, Ext Core and Chrome Frame
Simply load your JavaScript framework of choice:
echo $html->jsLoad('yui');
echo $html->jsLoad('dojo');
echo $html->jsLoad('prototype');
echo $html->jsLoad(array('prototype', 'scriptaculous')); //script.aculo.us depends on prototype
echo $html->jsLoad('jquery');
echo $html->jsLoad(array('jquery', 'jqueryui')); //jQueryUI depends on jQuery
echo $html->jsLoad('ext-core');
echo $html->jsLoad('chrome-frame');
echo $html->jsLoad('swfobject');
echo $html->jsLoad('mootools');
And their libraries are ready to use.