caisson 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in caisson.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2013 De Marque inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ Caisson
2
+ ===============
3
+
4
+ Caisson will provide a set of tools to facilitate the integration of Zurb-Foundation to your Rails project.
5
+
6
+ Install
7
+ -------
8
+
9
+ ```
10
+ gem install caisson
11
+ ```
12
+
13
+ ### Rails 3
14
+
15
+ In your Gemfile:
16
+
17
+ ```ruby
18
+ gem 'zurb-foundation'
19
+ gem 'caisson'
20
+ ```
21
+
22
+ Orbit Slider
23
+ -----
24
+
25
+ ### Basic examples
26
+
27
+ ```erb
28
+ <%= orbit_slider ['apple', 'banana', 'peach'] do |fruit| %>
29
+ <h1>I like <%= fruit %></h1>
30
+ <% end %>
31
+ ```
32
+
33
+ ```erb
34
+ <% images = ["img1.jpg", "img2.jpg", "img3.jpg", "img4.jpg"] %>
35
+ <%= orbit_slider images, columns_per_slide: 2 do |img| %>
36
+ <img src="<%= img %>" />
37
+ <% end %>
38
+ ```
39
+
40
+ ### Supported parameters
41
+
42
+ <table>
43
+ <tr>
44
+ <th>Name</th>
45
+ <th>Default</th>
46
+ </tr>
47
+ <tr>
48
+ <td>advance_speed</td>
49
+ <td>4000</td>
50
+ </tr>
51
+ <tr>
52
+ <td>animation</td>
53
+ <td>horizontal-push</td>
54
+ </tr>
55
+ <tr>
56
+ <td>animation_speed</td>
57
+ <td>400</td>
58
+ </tr>
59
+ <tr>
60
+ <td>bullets</td>
61
+ <td>false</td>
62
+ </tr>
63
+ <tr>
64
+ <td>bullet_thumbs</td>
65
+ <td>false</td>
66
+ </tr>
67
+ <tr>
68
+ <td>bullet_thumbs_location</td>
69
+ <td></td>
70
+ </tr>
71
+ <tr>
72
+ <td>caption_animation</td>
73
+ <td>fade</td>
74
+ </tr>
75
+ <tr>
76
+ <td>caption_animation_speed</td>
77
+ <td>800</td>
78
+ </tr>
79
+ <tr>
80
+ <td>captions</td>
81
+ <td>false</td>
82
+ </tr>
83
+ <tr>
84
+ <td>class</td>
85
+ <td>slider</td>
86
+ </tr>
87
+ <tr>
88
+ <td>columns_per_slide</td>
89
+ <td>1</td>
90
+ </tr>
91
+ <tr>
92
+ <td>directional_nav</td>
93
+ <td>true</td>
94
+ </tr>
95
+ <tr>
96
+ <td>fluid</td>
97
+ <td>16x5</td>
98
+ </tr>
99
+ <tr>
100
+ <td>id</td>
101
+ <td></td>
102
+ </tr>
103
+ <tr>
104
+ <td>pause_on_hover</td>
105
+ <td>true</td>
106
+ </tr>
107
+ <tr>
108
+ <td>reset_timer_on_click</td>
109
+ <td>false</td>
110
+ </tr>
111
+ <tr>
112
+ <td>start_clock_on_mouse_out</td>
113
+ <td>true</td>
114
+ </tr>
115
+ <tr>
116
+ <td>start_clock_on_mouse_out_after</td>
117
+ <td>1000</td>
118
+ </tr>
119
+ <tr>
120
+ <td>timer</td>
121
+ <td>false</td>
122
+ </tr>
123
+ </table>
124
+
125
+ For more details on Orbit, see [Foundation - Orbit](http://foundation.zurb.com/docs/orbit.php).
126
+
127
+ Copyright
128
+ ---------
129
+
130
+ Copyright (c) 2013 De Marque inc. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+ require "rspec/core/rake_task"
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ desc "Run all specs in spec directory"
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.pattern = "spec/**/*_spec.rb"
9
+ end
10
+
11
+ task :default => :spec
@@ -0,0 +1,9 @@
1
+ class Caisson
2
+ constructor: () ->
3
+ $('div[data-caisson]').each (i, component) =>
4
+ switch $(component).data('caisson')
5
+ when 'orbit-slider' then new OrbitSlider $(component)
6
+
7
+
8
+
9
+ $ -> new Caisson
@@ -0,0 +1,2 @@
1
+ //= require ./base
2
+ //= require ./orbit-slider
@@ -0,0 +1,34 @@
1
+ #*************************************************************************************
2
+ # TOCOMMENT
3
+ #*************************************************************************************
4
+ class @OrbitSlider
5
+ constructor: (@holder) ->
6
+ @holder.orbit @buildAttributes()
7
+
8
+
9
+ buildAttributes: () ->
10
+ {
11
+ advanceSpeed: @getAttr('advance-speed'),
12
+ animation: @getAttr('animation'),
13
+ animationSpeed: @getAttr('animation-speed'),
14
+ bulletThumbLocation: @getAttr('bullet-thumb-location'),
15
+ bulletThumbs: @getBoolAttr('bullet-thumbs'),
16
+ bullets: @getBoolAttr('bullets'),
17
+ captionAnimation: @getAttr('caption-animation'),
18
+ captionAnimationSpeed: @getAttr('caption-animation-speed'),
19
+ captions: @getBoolAttr('captions'),
20
+ directionalNav: @getBoolAttr('directional-nav'),
21
+ fluid: @getAttr('fluid'),
22
+ pauseOnHover: @getBoolAttr('pause-on-hover'),
23
+ resetTimerOnClick: @getBoolAttr('reset-timer-on-click'),
24
+ startClockOnMouseOut: @getBoolAttr('start-clock-on-mouse-out'),
25
+ startClockOnMouseOutAfter: @getAttr('start-clock-on-mouse-out-after'),
26
+ timer: @getBoolAttr('timer')
27
+ }
28
+
29
+ getAttr: (name) -> @holder.data(name),
30
+
31
+ getBoolAttr: (name) -> if String(@holder.data(name)) is '1' then true else false
32
+
33
+
34
+
@@ -0,0 +1,5 @@
1
+ module Caisson
2
+ class Engine < Rails::Engine
3
+ #auto wire
4
+ end
5
+ end
@@ -0,0 +1,100 @@
1
+ module Caisson::Helpers
2
+ class OrbitSlider
3
+ attr_reader :core
4
+
5
+ delegate :capture, to: :core
6
+ delegate :content_tag, to: :core
7
+
8
+ def initialize(core, items, options={})
9
+ @options = build_options options
10
+
11
+ @core = core
12
+ @items = items
13
+ end
14
+
15
+ def generate(&block)
16
+ wrap_slider build_slides(&block)
17
+ end
18
+
19
+ private
20
+
21
+ def build_options(options)
22
+ options.reverse_merge(
23
+ advance_speed: 4000,
24
+ animation: "horizontal-push",
25
+ animation_speed: 400,
26
+ bullets: false,
27
+ bullet_thumbs: false,
28
+ bullet_thumbs_location: '',
29
+ caption_animation: 'fade',
30
+ caption_animation_speed: 800,
31
+ captions: false,
32
+ class: 'slider',
33
+ columns_per_slide: 1,
34
+ directional_nav: true,
35
+ fluid: '16x5',
36
+ id: "slider-#{rand(10000)}",
37
+ pause_on_hover: true,
38
+ reset_timer_on_click: false,
39
+ start_clock_on_mouse_out: true,
40
+ start_clock_on_mouse_out_after: 1000,
41
+ timer: false)
42
+ end
43
+
44
+ def build_item(item, last=false, &block)
45
+ css_class = ['column']
46
+ css_class << get_column_size
47
+ css_class << 'end' if last
48
+
49
+ '<li class="' + css_class.join(' ') + '">' + capture(item, &block).to_s + '</li>'
50
+ end
51
+
52
+ def build_slides(&block)
53
+ slides = []
54
+
55
+ @items.each_slice @options[:columns_per_slide] do |slice|
56
+ content = '<div><ul class="row">'
57
+ slice.each_with_index { |item,i| content << build_item(item, (i==slice.length-1), &block) }
58
+ content << '</ul></div>'
59
+
60
+ slides << content
61
+ end
62
+
63
+ return slides.join("\n")
64
+ end
65
+
66
+ def get_column_size
67
+ case @options[:columns_per_slide]
68
+ when 1 then 'twelve'
69
+ when 2 then 'six'
70
+ when 3 then 'four'
71
+ when 4 then 'three'
72
+ when 5,6 then 'two'
73
+ else 'one'
74
+ end
75
+ end
76
+
77
+ def parse_attribute_value(raw_value)
78
+ case raw_value
79
+ when true then '1'
80
+ when false then '0'
81
+ else raw_value
82
+ end
83
+ end
84
+
85
+ def wrap_slider(content)
86
+ attributes = { 'data-caisson' => 'orbit-slider' }
87
+
88
+ @options.each do |k,v|
89
+ case k.to_s
90
+ when 'id' then attributes[:id] = v
91
+ when 'class' then attributes[:class] = ['slider', v].compact.join(' ')
92
+ when 'columns_per_slide' then nil
93
+ else attributes["data-#{k}".gsub('_', '-')] = parse_attribute_value(v)
94
+ end
95
+ end
96
+
97
+ return content_tag(:div, content.html_safe, attributes)
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,9 @@
1
+ module Caisson::Helpers
2
+ def orbit_slider(items, options={}, &block)
3
+ Caisson::Helpers::OrbitSlider.new(self, items, options).generate(&block)
4
+ end
5
+
6
+ ::ActionView::Base.send :include, self
7
+ end
8
+
9
+ require 'caisson/helpers/orbit_slider'
@@ -0,0 +1,9 @@
1
+ module Caisson::Implants
2
+ class Railtie < Rails::Railtie
3
+ initializer "caisson" do |app|
4
+ ActiveSupport.on_load :action_view do
5
+ require 'caisson/helpers'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Caisson
2
+ module Implants
3
+ end
4
+ end
5
+
6
+ if defined? Rails::Railtie
7
+ require 'caisson/implants/railtie'
8
+ elsif defined? Rails::Initializer
9
+ raise "caisson is not compatible with Rails 2.3 or older"
10
+ end
data/lib/caisson.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Caisson
2
+ end
3
+
4
+ require "caisson/engine"
5
+ require 'caisson/implants'
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caisson do
4
+
5
+ context 'with this particular fixture' do
6
+
7
+ describe "#method" do
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require 'rspec'
5
+
6
+ require File.expand_path('../../lib/caisson', __FILE__)
7
+
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :rspec
12
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caisson
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sebastien Rosa
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ requirement: &2159519640 !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.7
20
+ none: false
21
+ prerelease: false
22
+ type: :development
23
+ name: rake
24
+ version_requirements: *2159519640
25
+ - !ruby/object:Gem::Dependency
26
+ requirement: &2159540920 !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '2.0'
31
+ none: false
32
+ prerelease: false
33
+ type: :development
34
+ name: rspec
35
+ version_requirements: *2159540920
36
+ description: Caisson will provide a set of tools to facilitate the integration of
37
+ Zurb-Foundation to your Rails project.
38
+ email:
39
+ - sebastien@demarque.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files:
43
+ - LICENSE
44
+ - README.md
45
+ files:
46
+ - app/assets/javascripts/caisson/base.coffee
47
+ - app/assets/javascripts/caisson/index.js
48
+ - app/assets/javascripts/caisson/orbit-slider.coffee
49
+ - lib/caisson/engine.rb
50
+ - lib/caisson/helpers/orbit_slider.rb
51
+ - lib/caisson/helpers.rb
52
+ - lib/caisson/implants/railtie.rb
53
+ - lib/caisson/implants.rb
54
+ - lib/caisson.rb
55
+ - spec/caisson_spec.rb
56
+ - spec/spec_helper.rb
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - Gemfile
61
+ homepage: https://github.com/demarque/caisson
62
+ licenses:
63
+ - MIT
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ none: false
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ none: false
80
+ requirements: []
81
+ rubyforge_project: caisson
82
+ rubygems_version: 1.8.10
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Rails helpers for Zurb-Foundation Framework.
86
+ test_files: []
87
+ has_rdoc: