dynamojs_rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +10 -0
- data/dynamojs_rails.gemspec +23 -0
- data/lib/dynamojs_rails.rb +9 -0
- data/lib/dynamojs_rails/engine.rb +11 -0
- data/lib/dynamojs_rails/helpers.rb +28 -0
- data/lib/dynamojs_rails/version.rb +3 -0
- data/spec/dynamo_spec.rb +37 -0
- data/spec/spec_helper.rb +23 -0
- data/vendor/assets/javascripts/dynamo.js +5 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 4b27158e09639d9e4c72e00b5bf7ae3481cf5b9e
|
4
|
+
data.tar.gz: 00de2a782d9ac4ac29d339eba6229f22b134d8ec
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: 0ec0c7e40485fbf1660cd073d48e1a8fe0606dc9a568a723f340c4d48375d1a7ef4eac8ebcfe4ea5b0131441f887d2d5d6f489c940b336a9d1ffadaf1fd73fe2
|
7
|
+
data.tar.gz: ea849be6b0fb2234388c7c3d9e2bfc6ff3006d2f0226546274f1aa7f6580c7fb7c7c866807e470aaeff65cb5b7dadce4755c6e34ee5d744966eaffe2c22ec400
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Hank Stoever
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# dynamojs_rails
|
2
|
+
|
3
|
+
A light wrapper for using [dynamo.js](http://jordanscales.com/dynamo/) with Ruby on Rails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
In your `Gemfile`:
|
8
|
+
|
9
|
+
~~~Ruby
|
10
|
+
gem 'dynamojs_rails'
|
11
|
+
~~~
|
12
|
+
|
13
|
+
Then run:
|
14
|
+
|
15
|
+
~~~
|
16
|
+
$ bundle
|
17
|
+
~~~
|
18
|
+
|
19
|
+
Include `dynamo` in `app/assets/javascripts/application.js`
|
20
|
+
|
21
|
+
~~~
|
22
|
+
//= require dynamo
|
23
|
+
~~~
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
~~~Ruby
|
28
|
+
dynamo_tag :span, %w{one two}
|
29
|
+
# => <span class="dynamo" data-lines="two">one</span>
|
30
|
+
|
31
|
+
dynamo_tag :h2, %w{one two}, {
|
32
|
+
center: true,
|
33
|
+
speed: 100,
|
34
|
+
delay: 1000,
|
35
|
+
pause: true,
|
36
|
+
callback: "dynamoCallback",
|
37
|
+
class: "blinking"
|
38
|
+
}
|
39
|
+
# => <span class="blinking dynamo" data-callback="dynamoCallback" data-center="true"
|
40
|
+
data-delay="1000" data-lines="two" data-pause="true" data-speed="100">one</span>
|
41
|
+
~~~
|
42
|
+
|
43
|
+
All elements with the `.dynamo` class will are already invoked with `$.dynamo()`
|
44
|
+
|
45
|
+
### Options
|
46
|
+
|
47
|
+
* `speed`: the speed of the transition (*default: 350ms*)
|
48
|
+
* `delay`: the delay between transitions (*default: 3000ms*)
|
49
|
+
* `center`: center the text in the dynamo container (*default: false*)
|
50
|
+
* `pause`: sets up the dynamo, but does not automatically transition (*default: false*)
|
51
|
+
* `callback`: a javascript function name to be called each time the dynamo container completes a full cycle
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Add a test for it in `spec/dynamo_spec.rb` and make sure tests pass when you run `rake`
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc "Run specs"
|
5
|
+
RSpec::Core::RakeTask.new do |t|
|
6
|
+
# t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
7
|
+
# Put spec opts in a file named .rspec in root
|
8
|
+
end
|
9
|
+
|
10
|
+
task default: :spec
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dynamojs_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dynamojs_rails"
|
8
|
+
spec.version = DynamojsRails::VERSION
|
9
|
+
spec.authors = ["Hank Stoever"]
|
10
|
+
spec.email = ["hstove@gmail.com"]
|
11
|
+
spec.description = %q{A light wrapper for using dynamo.js with Ruby on Rails}
|
12
|
+
spec.summary = %q{A light wrapper for using dynamo.js with Ruby on Rails}
|
13
|
+
spec.homepage = "https://github.com/hstove/dynamojs_rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Dir[File.expand_path('../dynamojs_rails/*', __FILE__)].each { |f| require f }
|
2
|
+
|
3
|
+
module DynamojsRails
|
4
|
+
# if defined?(::Rails) and Gem::Requirement.new('>= 3.1').satisfied_by?(Gem::Version.new ::Rails.version)
|
5
|
+
# class Rails::Engine < ::Rails::Engine
|
6
|
+
# # this class enables the asset pipeline
|
7
|
+
# end
|
8
|
+
# end
|
9
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DynamojsRails
|
2
|
+
module Helpers
|
3
|
+
SHORTHANDS = %w{pause delay speed center delay callback}
|
4
|
+
# el is the html element type, like :span
|
5
|
+
# options are the dynamo options, like w%{first second}
|
6
|
+
def dynamo_tag el, options, config={}
|
7
|
+
config.symbolize_keys
|
8
|
+
first = options.shift
|
9
|
+
config["data-lines"] = options.join(",")
|
10
|
+
c = config[:class]
|
11
|
+
if c.blank?
|
12
|
+
c = "dynamo"
|
13
|
+
else
|
14
|
+
c += " dynamo"
|
15
|
+
end
|
16
|
+
config[:class] = c
|
17
|
+
new_config = {}
|
18
|
+
config.each do |key, val|
|
19
|
+
if SHORTHANDS.include? key.to_s
|
20
|
+
new_config["data-#{key}"] = val
|
21
|
+
else
|
22
|
+
new_config[key] = val
|
23
|
+
end
|
24
|
+
end
|
25
|
+
content_tag el, first, new_config
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/dynamo_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe DynamojsRails::Helpers do
|
3
|
+
include DynamojsRails::Helpers
|
4
|
+
|
5
|
+
it "creates the correct type of html element" do
|
6
|
+
html = dynamo_tag :span, %w{one two}
|
7
|
+
# puts html
|
8
|
+
html.should include("<span")
|
9
|
+
html.should include("one</span>")
|
10
|
+
html = dynamo_tag :h2, %w{one two}
|
11
|
+
html.should include("<h2")
|
12
|
+
html.should include("one</h2>")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "sets the correct shorthand options" do
|
16
|
+
html = dynamo_tag :span, %w{one two}, {
|
17
|
+
center: true,
|
18
|
+
speed: 100,
|
19
|
+
delay: 1000,
|
20
|
+
pause: true,
|
21
|
+
callback: "dynamo_callback"
|
22
|
+
}
|
23
|
+
# puts html
|
24
|
+
html.should include('data-center="true"')
|
25
|
+
html.should include('data-speed="100"')
|
26
|
+
html.should include('data-delay="1000"')
|
27
|
+
html.should include('data-pause="true"')
|
28
|
+
html.should include('data-callback="dynamo_callback"')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "sets the .dynamo class" do
|
32
|
+
html = dynamo_tag :span, %w{one two}
|
33
|
+
html.should include('class="dynamo"')
|
34
|
+
html = dynamo_tag :a, %w{one two}, class: 'btn'
|
35
|
+
html.should include('class="btn dynamo"')
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'dynamojs_rails'
|
8
|
+
require 'rails'
|
9
|
+
require 'action_view'
|
10
|
+
require 'active_support'
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
15
|
+
config.include ActionView::Helpers::TagHelper
|
16
|
+
config.include DynamojsRails::Helpers
|
17
|
+
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
config.order = 'random'
|
23
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
(function($){$.fn.dynamo=function(options){return this.each(function(i,v){options=options||{};var v=$(v);if(v.data("initialized")=="true")return;var delay=options.delay||parseInt(v.data("delay"))||3e3;var speed=options.speed||parseInt(v.data("speed"))||350;var pause=options.pause||v.data("pause")||false;var lines=options.lines||v.data("lines").split(v.data("delimiter")||",");var callback=options.callback||v.data("callback")||function(){};v.html($("<span></span>").text(v.text())).data("initialized","true");var max=v.find("span:eq(0)").width();for(k in lines){var span=$("<span></span>").text(lines[k]);v.append(span);max=Math.max(max,span.width())}v.find("span").each(function(i,ele){s=$(ele).remove();d=$("<div></div>").text(s.text());if(!i){d.data("trigger","true")}d.width(max);v.append(d)});var height=v.find(">:first-child").height();v.width(max).height(height).css({display:"inline-block",position:"relative",overflow:"hidden","vertical-align":"bottom","text-align":"left"});if(v.data("center"))v.css("text-align","center");var transition=function(){v.dynamo_trigger({speed:speed,callback:callback})};if(!pause){setInterval(transition,delay)}})};$.fn.dynamo_trigger=function(options){return this.each(function(i,v){options=options||{};var speed=options.speed||$(v).data("speed")||350;var callback=options.callback||$(v).data("callback")||function(){};$(v).find("div:first").slideUp(speed,function(){$(v).append($(this).show());if($(v).find("div:first").data("trigger")=="true")eval(callback).call()})})};$(".dynamo").dynamo()})(jQuery);
|
2
|
+
|
3
|
+
$(document).ready(function(){
|
4
|
+
$('.dynamo').dynamo();
|
5
|
+
});
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynamojs_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hank Stoever
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A light wrapper for using dynamo.js with Ruby on Rails
|
42
|
+
email:
|
43
|
+
- hstove@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .rspec
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- dynamojs_rails.gemspec
|
55
|
+
- lib/dynamojs_rails.rb
|
56
|
+
- lib/dynamojs_rails/engine.rb
|
57
|
+
- lib/dynamojs_rails/helpers.rb
|
58
|
+
- lib/dynamojs_rails/version.rb
|
59
|
+
- spec/dynamo_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- vendor/assets/javascripts/dynamo.js
|
62
|
+
homepage: https://github.com/hstove/dynamojs_rails
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.0.3
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: A light wrapper for using dynamo.js with Ruby on Rails
|
86
|
+
test_files:
|
87
|
+
- spec/dynamo_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
has_rdoc:
|