HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbScrollSpy.php
Go to the documentation of this file.
1 <?php
18 class TbScrollSpy extends CWidget
19 {
23  public $selector = 'body';
24 
28  public $target;
29 
33  public $offset;
34 
38  public $events = array();
39 
45  public function run()
46  {
47  $script = "jQuery('{$this->selector}').attr('data-spy', 'scroll');";
48 
49  if (isset($this->target)) {
50  $script .= "jQuery('{$this->selector}').attr('data-target', '{$this->target}');";
51  }
52 
53  if (isset($this->offset)) {
54  $script .= "jQuery('{$this->selector}').attr('data-offset', '{$this->offset}');";
55  }
56 
58  $cs = Yii::app()->getClientScript();
59  $cs->registerScript(__CLASS__ . '#' . $this->selector, $script, CClientScript::POS_BEGIN);
60 
61  foreach ($this->events as $name => $handler) {
62  $handler = CJavaScript::encode($handler);
63  $cs->registerScript(
64  __CLASS__ . '#' . $this->selector . '_' . $name,
65  "jQuery('{$this->selector}').on('{$name}', {$handler});"
66  );
67  }
68  }
69 }
70