stable-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@stable-rails --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stable-rails.gemspec
4
+ gemspec
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ stable-rails (0.0.1)
5
+ haml-rails
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (3.2.10)
11
+ activemodel (= 3.2.10)
12
+ activesupport (= 3.2.10)
13
+ builder (~> 3.0.0)
14
+ erubis (~> 2.7.0)
15
+ journey (~> 1.0.4)
16
+ rack (~> 1.4.0)
17
+ rack-cache (~> 1.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.2.1)
20
+ activemodel (3.2.10)
21
+ activesupport (= 3.2.10)
22
+ builder (~> 3.0.0)
23
+ activesupport (3.2.10)
24
+ i18n (~> 0.6)
25
+ multi_json (~> 1.0)
26
+ builder (3.0.4)
27
+ erubis (2.7.0)
28
+ haml (3.1.7)
29
+ haml-rails (0.3.5)
30
+ actionpack (>= 3.1, < 4.1)
31
+ activesupport (>= 3.1, < 4.1)
32
+ haml (~> 3.1)
33
+ railties (>= 3.1, < 4.1)
34
+ hike (1.2.1)
35
+ i18n (0.6.1)
36
+ journey (1.0.4)
37
+ json (1.7.6)
38
+ multi_json (1.5.0)
39
+ rack (1.4.1)
40
+ rack-cache (1.2)
41
+ rack (>= 0.4)
42
+ rack-ssl (1.3.2)
43
+ rack
44
+ rack-test (0.6.2)
45
+ rack (>= 1.0)
46
+ railties (3.2.10)
47
+ actionpack (= 3.2.10)
48
+ activesupport (= 3.2.10)
49
+ rack-ssl (~> 1.3.2)
50
+ rake (>= 0.8.7)
51
+ rdoc (~> 3.4)
52
+ thor (>= 0.14.6, < 2.0)
53
+ rake (10.0.3)
54
+ rdoc (3.12)
55
+ json (~> 1.4)
56
+ sprockets (2.2.2)
57
+ hike (~> 1.2)
58
+ multi_json (~> 1.0)
59
+ rack (~> 1.0)
60
+ tilt (~> 1.1, != 1.3.0)
61
+ thor (0.16.0)
62
+ tilt (1.3.3)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ stable-rails!
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brian J. Cardiff
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # Stable::Rails
2
+
3
+ Scrollable table with fixed first row and column.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'stable-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install stable-rails
18
+
19
+ ## Usage
20
+
21
+ In application.js include
22
+
23
+ //= require stable
24
+
25
+ In application.css include
26
+
27
+ *= require stable
28
+
29
+ To render a sample scrollable table
30
+
31
+ - stable do
32
+ - tr do
33
+ - td 'L\N'
34
+ - td 'Title 1'
35
+ - td 'Title 2'
36
+ - td 'Title 3'
37
+ - td 'Title 4'
38
+ - td 'Title 5'
39
+ - ('a'..'z').each do |c|
40
+ - tr do
41
+ - td "Title #{c}"
42
+ - td "#{c}1"
43
+ - td "#{c}2"
44
+ - td "#{c}3"
45
+ - td "#{c}4"
46
+ - td "#{c}5"
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ //= require stable/jquery.mousewheel
2
+ //= require stable/stable
3
+ //= require_self
4
+
@@ -0,0 +1,84 @@
1
+ /*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
2
+ * Licensed under the MIT License (LICENSE.txt).
3
+ *
4
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
6
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
7
+ *
8
+ * Version: 3.0.6
9
+ *
10
+ * Requires: 1.2.2+
11
+ */
12
+
13
+ (function($) {
14
+
15
+ var types = ['DOMMouseScroll', 'mousewheel'];
16
+
17
+ if ($.event.fixHooks) {
18
+ for ( var i=types.length; i; ) {
19
+ $.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
20
+ }
21
+ }
22
+
23
+ $.event.special.mousewheel = {
24
+ setup: function() {
25
+ if ( this.addEventListener ) {
26
+ for ( var i=types.length; i; ) {
27
+ this.addEventListener( types[--i], handler, false );
28
+ }
29
+ } else {
30
+ this.onmousewheel = handler;
31
+ }
32
+ },
33
+
34
+ teardown: function() {
35
+ if ( this.removeEventListener ) {
36
+ for ( var i=types.length; i; ) {
37
+ this.removeEventListener( types[--i], handler, false );
38
+ }
39
+ } else {
40
+ this.onmousewheel = null;
41
+ }
42
+ }
43
+ };
44
+
45
+ $.fn.extend({
46
+ mousewheel: function(fn) {
47
+ return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
48
+ },
49
+
50
+ unmousewheel: function(fn) {
51
+ return this.unbind("mousewheel", fn);
52
+ }
53
+ });
54
+
55
+
56
+ function handler(event) {
57
+ var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
58
+ event = $.event.fix(orgEvent);
59
+ event.type = "mousewheel";
60
+
61
+ // Old school scrollwheel delta
62
+ if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
63
+ if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
64
+
65
+ // New school multidimensional scroll (touchpads) deltas
66
+ deltaY = delta;
67
+
68
+ // Gecko
69
+ if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
70
+ deltaY = 0;
71
+ deltaX = -1*delta;
72
+ }
73
+
74
+ // Webkit
75
+ if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
76
+ if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
77
+
78
+ // Add event and delta to the front of the arguments
79
+ args.unshift(event, delta, deltaX, deltaY);
80
+
81
+ return ($.event.dispatch || $.event.handle).apply(this, args);
82
+ }
83
+
84
+ })(jQuery);
@@ -0,0 +1,46 @@
1
+ (function($) {
2
+
3
+ $.fn.stable = function() {
4
+ var stable = $(this);
5
+ var top_left_cell = $('.top_left', stable);
6
+
7
+ $('#scroll-vertical div', stable).height($('.c-right', stable).height());
8
+ $('#scroll-horizontal div', stable).width($('.c-right', stable).width());
9
+
10
+ stable.css('padding-bottom', top_left_cell.outerHeight());
11
+ stable.css('padding-right', top_left_cell.outerWidth());
12
+
13
+ stable.addClass('on');
14
+
15
+ // Para el Scroll VERTICAL
16
+ $('#scroll-vertical', stable).scroll(function(){
17
+ $('.vertical', stable).scrollTop($(this).scrollTop());
18
+ });
19
+
20
+ // Para el Scroll HORIZONTAL
21
+ $('#scroll-horizontal', stable).scroll(function(){
22
+ $('.horizontal', stable).scrollLeft($(this).scrollLeft());
23
+ });
24
+
25
+ // Para la tabla
26
+ $('#mask', stable).mousewheel(function(event, delta, deltaX, deltaY) {
27
+ if (!stable.hasClass('on')) return;
28
+
29
+ var newLeft = $('.horizontal', stable).scrollLeft() + 25 * deltaX;
30
+ var newTop = $('.vertical', stable).scrollTop() - 25 * deltaY;
31
+
32
+ $('.horizontal', stable).scrollLeft(newLeft);
33
+ $('.vertical', stable).scrollTop(newTop);
34
+
35
+ $('#scroll-horizontal', stable).scrollLeft(newLeft);
36
+ $('#scroll-vertical', stable).scrollTop(newTop);
37
+
38
+ event.preventDefault();
39
+ });
40
+ };
41
+
42
+ $(function(){
43
+ $('.stable').stable();
44
+ });
45
+
46
+ })(jQuery);
@@ -0,0 +1,41 @@
1
+ /* -- TABLA CON SCROLL APAGADO -- */
2
+ .table-scroll {
3
+ position:relative;
4
+ margin:0 auto; /*-- tabla centrada --*/
5
+ margin-bottom:30px;
6
+ }
7
+ .table-scroll #scroll-vertical { display:none }
8
+ .table-scroll #scroll-horizontal { display:none }
9
+
10
+ /* -- TABLA CON SCROLL ENCENDIDO -- */
11
+ .table-scroll.on {
12
+ position:relative;
13
+ margin-bottom:30px;
14
+ width:80%; height:200px /*-- aplicados para este ejemplo en particular --*/;
15
+ }
16
+
17
+ .table-scroll.on #mask { height:inherit; width:100%; overflow:hidden; white-space:nowrap; font-size:0; padding-bottom:inherit; padding-right:inherit }
18
+ .table-scroll #mask { white-space:nowrap; font-size:0; }
19
+
20
+ .table-scroll.on #scrollbars { position:relative; width:100%; height:inherit; padding-bottom:inherit; padding-right:inherit }
21
+ .table-scroll.on #scroll-vertical { position:absolute; height:100%; width:18px; right:-17px; z-index:100; overflow-y:scroll; display:block }
22
+ .table-scroll.on #scroll-horizontal { position:absolute; height:18px; width:100%; left:0px; bottom:-17px; z-index:100; overflow-x:scroll; display:block }
23
+ .table-scroll.on #scroll-horizontal div { height:1px }
24
+
25
+
26
+ /* -- ESTRUCTURA GRAL DE LA TABLA-- */
27
+ .c-left, .c-right { display:inline-block; vertical-align:top; height:inherit }
28
+ .c-right { width:inherit }
29
+
30
+ .t-header { background:#333333; color:#FFFFFF; overflow:hidden }
31
+ .t-body { height:inherit; overflow:hidden }
32
+ .t-row { font-size:0 }
33
+ .t-row div { border:1px solid #999; font-size:11pt; display:inline-block; height:20px; overflow:hidden }
34
+
35
+ /* ----- ANCHO de CELDAS para este ejemplo ----- */
36
+ .table-scroll.w120 .t-row div { width:120px; padding:5px }
37
+
38
+ /* ----- ANCHO PARTICULAR de celdas a modo de ejemplo ----- */
39
+ .w200 { width:200px !important; }
40
+
41
+
@@ -0,0 +1,94 @@
1
+ module StableHelper
2
+
3
+ def stable(html_options = nil)
4
+ @builder = STableBuilder.new(self)
5
+ @builder.table(html_options) do
6
+ yield
7
+ end
8
+ end
9
+
10
+ def table(html_options = nil)
11
+ @builder = TableBuilder.new(self)
12
+ @builder.table(html_options) do
13
+ yield
14
+ end
15
+ end
16
+
17
+ def tr
18
+ @builder.tr do
19
+ yield
20
+ end
21
+ end
22
+
23
+ def td(content, options = {})
24
+ @builder.td content, options
25
+ end
26
+
27
+ end
28
+
29
+ class TableBuilder
30
+
31
+ def initialize(context)
32
+ @context = context
33
+ @row_index = -1
34
+ @column_html_options = []
35
+ end
36
+
37
+ def table(html_options)
38
+ @context.haml_tag :table, html_options do
39
+ yield
40
+ end
41
+ end
42
+
43
+ def tr
44
+ @row_index += 1
45
+ @col_index = -1
46
+
47
+ @context.haml_tag :tr do
48
+ yield
49
+ end
50
+ end
51
+
52
+ def td(content, options)
53
+ @col_index += 1
54
+
55
+ if @row_index == 0
56
+ @column_html_options << (options.delete(:column) || {})
57
+ end
58
+
59
+ @context.haml_tag :td, options.merge(@column_html_options[@col_index]) do
60
+ @context.haml_concat content
61
+ end
62
+ end
63
+ end
64
+
65
+ class STableBuilder
66
+
67
+ def initialize(context)
68
+ @context = context
69
+ @data = []
70
+ @column_html_options = []
71
+ end
72
+
73
+ def table(html_options)
74
+ yield
75
+
76
+ @context.haml_concat @context.render(:partial => '/stable/stable',
77
+ :locals => {
78
+ :data => @data,
79
+ :html_options => html_options,
80
+ :column_html_options => @column_html_options
81
+ }
82
+ )
83
+ end
84
+
85
+ def tr
86
+ @data << []
87
+ yield
88
+ end
89
+
90
+ def td(content, options)
91
+ @column_html_options << (options[:column] || {})
92
+ @data.last << content
93
+ end
94
+ end
@@ -0,0 +1,36 @@
1
+ .stable.table-scroll.w120{ html_options }
2
+ #scrollbars
3
+ #scroll-vertical
4
+ %div
5
+ #scroll-horizontal
6
+ %div
7
+ #mask
8
+ .c-left
9
+ .t-header
10
+ .t-row
11
+ %div.top_left{column_html_options[0]}
12
+ = data[0][0]
13
+ .t-body.vertical
14
+ - data.each_with_index do |row, index|
15
+ - next if index == 0
16
+ .t-row
17
+ %div{column_html_options[0]}
18
+ = row[0]
19
+ .c-right
20
+ .t-header.horizontal
21
+ .t-row
22
+ - data[0].each_with_index do |cell, index|
23
+ - next if index == 0
24
+ %div{column_html_options[index]}
25
+ = cell
26
+ .t-body.vertical.horizontal
27
+ - data.each_with_index do |row, index|
28
+ - next if index == 0
29
+ .t-row
30
+ - row.each_with_index do |cell, index|
31
+ - next if index == 0
32
+ %div{column_html_options[index]}
33
+ = cell
34
+
35
+
36
+
@@ -0,0 +1,8 @@
1
+ require "stable-rails/version"
2
+
3
+ module Stable
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Stable
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stable-rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "stable-rails"
8
+ gem.version = Stable::Rails::VERSION
9
+ gem.authors = ["Martin Scebba", "Brian J. Cardiff"]
10
+ gem.email = ["mscebba@manas.com.ar", "bcardiff@manas.com.ar"]
11
+ gem.description = %q{Scrollable table with fixed first row and column.}
12
+ gem.summary = %q{Rails gem that allows to easily include scrollable tables.}
13
+ gem.homepage = "https://github.com/manastech/stable-rails"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency 'haml-rails'
21
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stable-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Martin Scebba
9
+ - Brian J. Cardiff
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-01-04 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: haml-rails
17
+ requirement: &70259525148200 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70259525148200
26
+ description: Scrollable table with fixed first row and column.
27
+ email:
28
+ - mscebba@manas.com.ar
29
+ - bcardiff@manas.com.ar
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - .rvmrc
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - app/assets/javascripts/stable/index.js
42
+ - app/assets/javascripts/stable/jquery.mousewheel.js
43
+ - app/assets/javascripts/stable/stable.js
44
+ - app/assets/stylesheets/stable/index.scss
45
+ - app/helpers/stable_helper.rb
46
+ - app/views/stable/_stable.haml
47
+ - lib/stable-rails.rb
48
+ - lib/stable-rails/version.rb
49
+ - stable-rails.gemspec
50
+ homepage: https://github.com/manastech/stable-rails
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.10
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Rails gem that allows to easily include scrollable tables.
74
+ test_files: []