1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29: 30:
31: class StaticTabPanel extends TabPanel
32: {
33: private $indexes = array();
34:
35: 36: 37:
38: public function __wakeup()
39: {
40: parent::__wakeup();
41: PiconApplication::get()->addComponentRenderHeadListener(new JQueryRenderHeadListener());
42: }
43:
44: protected function setup()
45: {
46: PiconApplication::get()->addComponentRenderHeadListener(new JQueryRenderHeadListener());
47: $view = new RepeatingView(TabPanel::PANEL_ID);
48: $this->add($view);
49: foreach($this->getCollection()->tabs as $index => $tabItem)
50: {
51: $panel = $tabItem->newTab($view->getNextChildId());
52: $panel->setOutputMarkupId(true);
53: $this->indexes[$index] = $panel->getMarkupId();
54: $panel->add(new AttributeModifier('style', new BasicModel('display:none;')));
55: $view->add($panel);
56: }
57: }
58:
59: public function newLink($id, $index)
60: {
61: $switchLink = new MarkupContainer($id);
62: $switchLink->add(new AttributeModifier('href', new BasicModel(sprintf('javascript:;', $this->indexes[$index]))));
63: $switchLink->add(new AttributeModifier('onClick', new BasicModel(sprintf('$(\'#\'+currentTab).hide(); $(\'#%s\').show();currentTab = \'%s\'; $(\'li.selected\', $(this).parents(\'ul\').first()).removeClass(\'selected\'); $(this).parents(\'li\').first().addClass(\'selected\');', $this->indexes[$index], $this->indexes[$index]))));
64: return $switchLink;
65: }
66:
67: public function renderHead(HeaderResponse $headerResponse)
68: {
69: parent::renderHead($headerResponse);
70: $headerResponse->renderScript(sprintf('var currentTab; $(document).ready(function(){$(\'#%s\').show(); currentTab = \'%s\';});', $this->indexes[0], $this->indexes[0]));
71: }
72: }
73:
74: ?>
75: