52 lines
1.3 KiB
JavaScript
Executable File
52 lines
1.3 KiB
JavaScript
Executable File
// Generated by CoffeeScript 1.3.3
|
|
(function() {
|
|
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
|
|
|
this.Tab = (function() {
|
|
|
|
function Tab(id, items) {
|
|
this.id = id;
|
|
this.items = items;
|
|
this.onShow = __bind(this.onShow, this);
|
|
|
|
this.element = $("#tab_" + id);
|
|
this.render();
|
|
}
|
|
|
|
Tab.prototype.$ = function(selector) {
|
|
return $(selector, this.element);
|
|
};
|
|
|
|
Tab.prototype.render = function() {
|
|
var _this = this;
|
|
$.each(this.items, function(index, item) {
|
|
var tab;
|
|
tab = $('<a>').attr({
|
|
href: "#" + (_this.tabId(index))
|
|
}).html(item.title);
|
|
_this.$('.navigation').append($('<li>').append(tab));
|
|
return _this.element.append($('<section>').attr({
|
|
id: _this.tabId(index)
|
|
}));
|
|
});
|
|
return this.element.tabs({
|
|
show: this.onShow
|
|
});
|
|
};
|
|
|
|
Tab.prototype.onShow = function(element, ui) {
|
|
this.$('section.ui-tabs-hide').html('');
|
|
this.$("#" + (this.tabId(ui.index))).html(eval(this.items[ui.index]['content']));
|
|
return this.element.trigger('contentChanged');
|
|
};
|
|
|
|
Tab.prototype.tabId = function(index) {
|
|
return "tab-" + this.id + "-" + index;
|
|
};
|
|
|
|
return Tab;
|
|
|
|
})();
|
|
|
|
}).call(this);
|