Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Shadow Tabs in Magento's UI Object Hierarchy?

I'm poking around the Magento internals, and within the Widget/Tab rendering hierarchy there's this concept of Shadow Tabs that I'm a little fuzzy on. When you're defining tabs for your form, you can bind it as a shadow tab

protected function _prepareLayout()
{
    parent::_prepareLayout();
    $this->addTab('bundle_items', array(
        'label'     => Mage::helper('bundle')->__('Bundle Items'),
        'url'   => $this->getUrl('*/*/bundles', array('_current' => true)),
        'class' => 'ajax',
    ));
    $this->bindShadowTabs('bundle_items', 'customer_options');
}

The bindShadowTabs method is documents with

/**
 * Mark tabs as dependent of each other
 * Arbitrary number of tabs can be specified, but at least two
 *
 * @param string $tabOneId
 * @param string $tabTwoId
 * @param string $tabNId...
 */
public function bindShadowTabs($tabOneId, $tabTwoId)

The Javascript that leverages the PHP objects looks like

showTabContentImmediately : function(tab) {
    this.hideAllTabsContent();
    var tabContentElement = $(this.getTabContentElementId(tab));
    if (tabContentElement) {
        Element.show(tabContentElement);
        Element.addClassName(tab, 'active');
        // load shadow tabs, if any
        if (tab.shadowTabs && tab.shadowTabs.length) {
            for (var k in tab.shadowTabs) {
                this.loadShadowTab($(tab.shadowTabs[k]));
            }
        }
        if (!Element.hasClassName(tab, 'ajax only')) {
            Element.removeClassName(tab, 'notloaded');
        }
        this.activeTab = tab;
    }
    if (varienGlobalEvents) {
        varienGlobalEvents.fireEvent('showTab', {tab:tab});
    }
},

From a basic reading, it's not entirely clear to me what the implications of making one tab "dependent" on another is. Is this a simple "only render the bundle_item tab if the customer_options tab is rendered? Or something more?

like image 495
Alan Storm Avatar asked May 25 '11 19:05

Alan Storm


1 Answers

It seems like it means that whenever any of the tabs that are bound together as shadowTabs is displayed the other tabs in this grop will also be rendered.

so not "only render the bundle_item tab if the customer_options tab is rendered" but rather "whenever the bundle_item tab or the customer_options tab is rendered, render the other one as well".

not sure I like the metaphor of a shadow though.

like image 129
epeleg Avatar answered Nov 15 '22 14:11

epeleg