Source

yii-bootstrap / widgets / BootWidget.php

The branch 'nativejs' does not exist.
Full commit
<?php
/**
 * BootWidget class file.
 * @author Christoffer Niska <ChristofferNiska@gmail.com>
 * @copyright Copyright &copy; Christoffer Niska 2011-
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 */

/**
 * @todo DocBlock
 */
class BootWidget extends CWidget
{
	/**
	 * @var array the options for the Bootstrap JavaScript plugin.
	 */
	public $options = array();
	/**
	 * @var string[] the JavaScript event handlers.
	 */
	public $events = array();
	/**
	 * @var array the HTML attributes for the widget container.
	 */
	public $htmlOptions = array();

	/**
	 * Initializes the widget.
	 */
	public function init()
	{
		Yii::app()->clientScript->registerCoreScript('jquery');
		Yii::app()->clientScript->registerCoreScript('jquery.ui');
	}

	/**
	 * Registers a JavaScript file under Bootstrap.
	 * @param string $fileName the name of the JavaScript file
	 * @param integer $position the position of the JavaScript file
	 */
	protected function registerScriptFile($fileName, $position=CClientScript::POS_HEAD)
	{
		Yii::app()->bootstrap->registerScriptFile($fileName, $position);
	}

    /**
     * Registers a piece of javascript code.
     * @param string $id ID that uniquely identifies this piece of JavaScript code
     * @param string $script the javascript code
     * @param integer $position the position of the JavaScript code
     */
    protected function registerScript($id, $script, $position=CClientScript::POS_END)
    {
        Yii::app()->clientScript->registerScript($id, $script, $position);
    }
}