Sha256: 06b890d90ce3a200f5b8e2c70ac7908347c7434f3b4aec4802b10e6a4ccf9097

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

(function() {
  var $;
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    function ctor() { this.constructor = child; }
    ctor.prototype = parent.prototype;
    child.prototype = new ctor;
    child.__super__ = parent.prototype;
    return child;
  };
  if (typeof Spine === "undefined" || Spine === null) {
    Spine = require('spine');
  }
  $ = Spine.$;
  Spine.Tabs = (function() {
    __extends(Tabs, Spine.Controller);
    Tabs.prototype.events = {
      'click [data-name]': 'click'
    };
    function Tabs() {
      this.change = __bind(this.change, this);      Tabs.__super__.constructor.apply(this, arguments);
      this.bind('change', this.change);
    }
    Tabs.prototype.change = function(name) {
      if (!name) {
        return;
      }
      this.current = name;
      this.children().removeClass('active');
      return this.children("[data-name=" + this.current).addClass('active');
    };
    Tabs.prototype.render = function() {
      this.change(this.current);
      if (!(this.children('.active').length || this.current)) {
        return this.children(':first').click();
      }
    };
    Tabs.prototype.children = function(sel) {
      return this.el.children(sel);
    };
    Tabs.prototype.click = function(e) {
      var name;
      name = $(e.target).attr('data-name');
      return this.trigger('change', name);
    };
    Tabs.prototype.connect = function(tabName, controller) {
      return this.bind('change', function(name) {
        if (name === tabName) {
          return controller.active();
        }
      });
    };
    return Tabs;
  })();
  if (typeof module !== "undefined" && module !== null) {
    module.exports = Spine.Tabs;
  }
}).call(this);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spine-rails-0.0.8 app/assets/javascripts/spine/tabs.js