Phundament App Class Reference
  • Package
  • Class
  • Tree

Packages

  • bootstrap
    • widgets
      • input
  • Image
  • None
  • p3admin
  • p3extensions
    • behaviors
    • commands
    • components
    • helpers
    • widgets
  • p3media
    • actions
    • controllers
    • models
  • p3pages
    • models
  • p3widgets
    • components
    • models
  • PHP
  • system
    • db
      • ar
    • gii
    • web
      • auth
      • helpers
      • widgets
  • yiiext
    • widgets
      • fancybox
      • lipsum
  • zii
    • widgets
      • grid

Classes

  • TbActiveForm
  • TbAlert
  • TbBadge
  • TbBreadcrumbs
  • TbButton
  • TbButtonColumn
  • TbButtonGroup
  • TbCarousel
  • TbCollapse
  • TbDataColumn
  • TbDetailView
  • TbDropdown
  • TbGridView
  • TbHeroUnit
  • TbLabel
  • TbListView
  • TbMenu
  • TbModal
  • TbNavbar
  • TbPager
  • TbProgress
  • TbScrollSpy
  • TbTabs
  • TbThumbnails
  • TbTypeahead
 1 <?php
 2 /**
 3  * TbModal class file.
 4  * @author Christoffer Niska <ChristofferNiska@gmail.com>
 5  * @copyright Copyright &copy; Christoffer Niska 2011-
 6  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 7  * @package bootstrap.widgets
 8  * @since 0.9.3
 9  */
10 
11 /**
12  * Bootstrap modal widget.
13  * @see http://twitter.github.com/bootstrap/javascript.html#modals
14  */
15 class TbModal extends CWidget
16 {
17     /**
18      * @var boolean indicates whether to automatically open the modal. Defaults to 'false'.
19      */
20     public $autoOpen = false;
21     /**
22      * @var boolean indicates whether the modal should use transitions. Defaults to 'true'.
23      */
24     public $fade = true;
25     /**
26      * @var array the options for the Bootstrap Javascript plugin.
27      */
28     public $options = array();
29     /**
30      * @var string[] the Javascript event handlers.
31      */
32     public $events = array();
33     /**
34      * @var array the HTML attributes for the widget container.
35      */
36     public $htmlOptions = array();
37 
38     /**
39      * Initializes the widget.
40      */
41     public function init()
42     {
43         if (!isset($this->htmlOptions['id']))
44             $this->htmlOptions['id'] = $this->getId();
45 
46         if ($this->autoOpen === false && !isset($this->options['show']))
47             $this->options['show'] = false;
48 
49         $classes = array('modal');
50 
51         if ($this->fade === true)
52             $classes[] = 'fade';
53 
54         if (!empty($classes))
55         {
56             $classes = implode(' ', $classes);
57             if (isset($this->htmlOptions['class']))
58                 $this->htmlOptions['class'] .= ' '.$classes;
59             else
60                 $this->htmlOptions['class'] = $classes;
61         }
62 
63         echo CHtml::openTag('div', $this->htmlOptions);
64     }
65 
66     /**
67      * Runs the widget.
68      */
69     public function run()
70     {
71         $id = $this->htmlOptions['id'];
72 
73         echo '</div>';
74 
75         /** @var CClientScript $cs */
76         $cs = Yii::app()->getClientScript();
77 
78         $options = !empty($this->options) ? CJavaScript::encode($this->options) : '';
79         $cs->registerScript(__CLASS__.'#'.$id, "jQuery('#{$id}').modal({$options});");
80 
81         foreach ($this->events as $name => $handler)
82         {
83             $handler = CJavaScript::encode($handler);
84             $cs->registerScript(__CLASS__.'#'.$id.'_'.$name, "jQuery('#{$id}').on('{$name}', {$handler});");
85         }
86     }
87 }
88 
Phundament App Class Reference API documentation generated by ApiGen 2.8.0