THIS IS OUTDATED. For a better UI Framework "UIBase"
A lightweight modular JavaScript framework.
CoreJS is inspired by:
- The talk by Nicholas C. Zakas - "Scalable JavaScript Application Architecture" (Slides).
- This article by Addy Osmani.
- and scaleApp.
Please note, presently the internal modules are dependent on jQuery but feel free to modify them based on your preference.
corejs.register("tabs", function (sb) {
/* Factory function for tabs */
var root, changeTab, activeTab;
changeTab = function (showTab) {
$(root).find('.tab-link-item').removeClass('active');
$(root).find('a[href="' + showTab + '"]').parent('.tab-link-item').addClass('active');
$(root).find('.tabs-content .content').removeClass('active');
$(root).find(showTab).addClass('active');
activeTab = showTab;
};
return {
init: function (opts) {
root = opts.el;
activeTab = $(root).find('.tab-link-item.active').attr('href');
$(root).find('.tab-links').delegate('.tab-link-item', 'click', function (e) {
changeTab($(this).find('a').attr('href'));
sb.publish("tabChanged", {
"activeTab": $(this).find('a').attr('href')
});
});
},
destroy: function () {
$(root).find('.tab-links').undelegate('.tab-link-item', 'click');
}
};
}, {
/* Options for tabs */
'associatedClass': 'tabs-area'
});