Sha256: d4d7d0ad67557560d0aeb5aa46281c8e825279ad65865688b063cc91897ca38c

Contents?: true

Size: 1.77 KB

Versions: 3

Compression:

Stored size: 1.77 KB

Contents

(function($) {

  $.fn.stable = function() {
    return this.each(function() {
      var stable = $(this);

      var initialized = stable.hasClass('on');

      if (initialized) {
        // reset
        stable.removeClass('on');
        $('.scroll-vertical div', stable).height('auto');
        $('.scroll-horizontal div', stable).width('auto');
      }

      var top_left_cell = $('.c-left .t-header', stable);

      $('.scroll-vertical div', stable).height($('.c-right', stable).height());
      $('.scroll-horizontal div', stable).width($('.c-right', stable).width()+$('.c-left', stable).width()+15);

      stable.css('padding-bottom', top_left_cell.outerHeight());
      stable.css('padding-right', top_left_cell.outerWidth()+15);

      stable.addClass('on');

      if (!initialized) {
        // Para el Scroll VERTICAL
        $('.scroll-vertical', stable).scroll(function(){
           $('.vertical', stable).scrollTop($(this).scrollTop());
        });

        // Para el Scroll HORIZONTAL
        $('.scroll-horizontal', stable).scroll(function(){
           $('.horizontal', stable).scrollLeft($(this).scrollLeft());
        });

        // Para la tabla
        $('.mask', stable).mousewheel(function(event, delta, deltaX, deltaY) {
          if (!stable.hasClass('on')) return;

          var newLeft = $('.horizontal', stable).scrollLeft() + 25 * deltaX;
          var newTop = $('.vertical', stable).scrollTop() - 25 * deltaY;

          $('.horizontal', stable).scrollLeft(newLeft);
          $('.vertical', stable).scrollTop(newTop);

          $('.scroll-horizontal', stable).scrollLeft(newLeft);
          $('.scroll-vertical', stable).scrollTop(newTop);

          event.preventDefault();
        });
      }
    });
  };

  $(function(){
    $('.stable').stable();
  });

})(jQuery);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stable-rails-0.0.6 app/assets/javascripts/stable/stable.js
stable-rails-0.0.5 app/assets/javascripts/stable/stable.js
stable-rails-0.0.4 app/assets/javascripts/stable/stable.js