Skip to content

Instantly share code, notes, and snippets.

@vrkansagara
Forked from bekapod/js.js
Created May 3, 2016 09:42
Show Gist options
  • Save vrkansagara/c9f82d255c809af7f22698e77ca4c473 to your computer and use it in GitHub Desktop.
Save vrkansagara/c9f82d255c809af7f22698e77ca4c473 to your computer and use it in GitHub Desktop.
MAGENTO: Remotely trigger a Varien tab
Varien.Tabs = Class.create();
Varien.Tabs.prototype = {
initialize: function(selector) {
var self=this;
$$(selector+' a').each(this.initTab.bind(this));
},
initTab: function(el) {
el.href = 'javascript:void(0)';
if ($(el.parentNode).hasClassName('active')) {
this.showContent(el);
}
el.observe('click', this.showContent.bind(this, el));
},
showContent: function(a) {
var li = $(a.parentNode), ul = $(li.parentNode);
ul.getElementsBySelector('li').each(function(el){
var contents = $(el.id+'_contents');
if (el==li) {
el.addClassName('active');
contents.show();
} else {
el.removeClassName('active');
contents.hide();
}
});
},
remoteTabs: function(b) {
var controlledLink = $$("#"+b+" a")[0];
this.showContent(controlledLink);
}
}
var csTablist = new Varien.Tabs('.tabs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment