Pxxo_Widget_Javascript_YUI

This widget can be used to enable "Yahoo! User Interface" (YUI) library in your code.

This widget is a decorator, to know more about it (how to use it), please read the decorators documentation.

Parameters

Name Default value Description
version '2.5.2' the YUI version you want to use
modules array() array which contains the modules to load. Example : ""layout", "tabview", "animation", "container", "button", "editor"
client_on_success "" a string that contains the javascript to execute when the YUI is completely loaded
yui_skin 'yui-skin-sam' the YUI skin to use (a bit redundant with pxxo's themes)
loadOptional false Should loader load optional dependencies for the components you're requesting?
combine false If set to true, YUI files will be combined into a single request using the combo service provided on the Yahoo! CDN
base "" Allows you to specify a different location (as a full or relative filepath) for the YUI build directory. By default, YUI Loader will serve files from Yahoo's servers.

Examples

First of all, decorate your widget:

...
        $this->addDecorator('Pxxo_Widget_Javascript_YUI',
                            array('modules' => array("layout",
                                                     "tabview",
                                                     "animation",
                                                     "container",
                                                     "button",
                                                     "editor"),
                                  'client_on_success' => 'MyBuildGUI();'));
...

Then in your template define the hooks (html) needed by your code. Thanks to these hooks you will be able to connect YUI widgets to it. In this example we prepare a HTML structure that will display a TABVIEW:

<div id="<?php echo $ClassID; ?>">
 
  <div id="demo" class="yui-navset">
      <ul class="yui-nav">
          <li class="selected"><a href="#tab1"><em>Tab One Label</em></a></li>
          <li><a href="#tab2"><em>Tab Two Label</em></a></li>
          <li><a href="#tab3"><em>Tab Three Label</em></a></li>
      </ul>            
      <div class="yui-content">
          <div><p>Tab One Content</p></div>
          <div><p>Tab Two Content</p></div>
          <div><p>Tab Three Content</p></div>
      </div>
  </div>
 
</div>

Then in a javascript template, define your function that will be executed when YUI is ready. In this example we connect a YUI tabview to our html structure and we add dynamically (with javascript) a new tab to this tabview:

function MyBuildGUI() {
  var myTabs = new YAHOO.widget.TabView("demo");
  myTabs.addTab( new YAHOO.widget.Tab({
        label: 'My dynamic tab',
        content: '<p>this tab is created using javascript function</p>'
  }));
}
en/doc/pxxo_widget_javascript_yui.txt · Last modified: 2012/01/14 00:12 (external edit)
 
 

©2003-2012 Pxxo

Partenaires : INIST-CNRS | Sourcesup | Web2.0 chat server | Jeux gratuits