youthtree-js 0.1.0
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.
- data/README.md +27 -0
- data/Rakefile +29 -0
- data/coffeescripts/youth_tree/gallery.coffee +34 -0
- data/coffeescripts/youth_tree.coffee +4 -0
- data/javascripts/youth_tree/gallery.js +42 -0
- data/javascripts/youth_tree.js +3 -0
- data/lib/youthtree-js.rb +10 -0
- data/youthtree-js.gemspec +44 -0
- metadata +74 -0
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# YouthTree JS #
|
2
|
+
|
3
|
+
A set of tools for common javascript functionality shared across YouthTree applications.
|
4
|
+
|
5
|
+
Developed primarily for [TEDxPerth](http://tedxperth.org/) and [Big Help Mob](http://bighelpmob.org/)
|
6
|
+
|
7
|
+
Relies on [Shuriken](http://github.com/Sutto/shuriken/).
|
8
|
+
|
9
|
+
## Contributing ##
|
10
|
+
|
11
|
+
We encourage all community contributions. Keeping this in mind, please follow these general guidelines when contributing:
|
12
|
+
|
13
|
+
* Fork the project
|
14
|
+
* Create a topic branch for what you’re working on (git checkout -b awesome_feature)
|
15
|
+
* Commit away, push that up (git push your\_remote awesome\_feature)
|
16
|
+
* Create a new GitHub Issue with the commit, asking for review. Alternatively, send a pull request with details of what you added.
|
17
|
+
* Once it’s accepted, if you want access to the core repository feel free to ask! Otherwise, you can continue to hack away in your own fork.
|
18
|
+
|
19
|
+
Other than that, our guidelines very closely match the GemCutter guidelines [here](http://wiki.github.com/qrush/gemcutter/contribution-guidelines).
|
20
|
+
|
21
|
+
(Thanks to [GemCutter](http://wiki.github.com/qrush/gemcutter/) for the contribution guide)
|
22
|
+
|
23
|
+
## License ##
|
24
|
+
|
25
|
+
All code is licensed under the New BSD License and is copyright YouthTree. Please keep this
|
26
|
+
in mind when contributing.
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'lib/youthtree-js'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "youthtree-js"
|
10
|
+
gem.summary = %Q{Shared Javascript tools across YouthTree apps.}
|
11
|
+
gem.description = %Q{Shared Javascript tools across YouthTree apps.}
|
12
|
+
gem.email = "sutto@sutto.net"
|
13
|
+
gem.homepage = "http://github.com/YouthTree/youthtree-js"
|
14
|
+
gem.version = YouthTreeJS::VERSION
|
15
|
+
gem.authors = ["Darcy Laycock"]
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Compiles the javascript from Coffeescript to Javascript"
|
23
|
+
task :compile_scripts do
|
24
|
+
Dir["coffeescripts/**/*.coffee"].each do |cs|
|
25
|
+
output = File.dirname(cs).gsub("coffeescripts", "javascripts")
|
26
|
+
system "coffee", "-c", "--no-wrap", cs, "-o", output
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
YouthTree.withNS 'Gallery', (ns) ->
|
2
|
+
|
3
|
+
class InnerGallery
|
4
|
+
|
5
|
+
constructor: (selector) ->
|
6
|
+
@selector: selector
|
7
|
+
@items: $ @selector
|
8
|
+
@urls: @items.map(-> @href).toArray()
|
9
|
+
|
10
|
+
bindEvents: ->
|
11
|
+
@items.click ->
|
12
|
+
showFor @
|
13
|
+
false
|
14
|
+
|
15
|
+
showFor: (element) ->
|
16
|
+
href: element.href
|
17
|
+
index: @urls.indexOf href
|
18
|
+
if index >= 0
|
19
|
+
showImages @urls.slice(index).concat(@urls.slice(0, index))
|
20
|
+
|
21
|
+
showImages: (images) ->
|
22
|
+
$.facybox {images: images}
|
23
|
+
|
24
|
+
ns.galleries: {}
|
25
|
+
|
26
|
+
ns.create: (name, selector) ->
|
27
|
+
gallery: new InnerGallery selector
|
28
|
+
ns.galleries[name]: gallery
|
29
|
+
gallery
|
30
|
+
|
31
|
+
ns.get: (name) ->
|
32
|
+
ns.galleries[name]
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
YouthTree.withNS('Gallery', function(ns) {
|
2
|
+
var InnerGallery;
|
3
|
+
InnerGallery = function(selector) {
|
4
|
+
this.selector = selector;
|
5
|
+
this.items = $(this.selector);
|
6
|
+
this.urls = this.items.map(function() {
|
7
|
+
return this.href;
|
8
|
+
}).toArray();
|
9
|
+
return this;
|
10
|
+
};
|
11
|
+
InnerGallery.prototype.bindEvents = function() {
|
12
|
+
return this.items.click(function() {
|
13
|
+
showFor(this);
|
14
|
+
return false;
|
15
|
+
});
|
16
|
+
};
|
17
|
+
InnerGallery.prototype.showFor = function(element) {
|
18
|
+
var href, index;
|
19
|
+
href = element.href;
|
20
|
+
index = this.urls.indexOf(href);
|
21
|
+
if (index >= 0) {
|
22
|
+
return showImages(this.urls.slice(index).concat(this.urls.slice(0, index)));
|
23
|
+
}
|
24
|
+
};
|
25
|
+
InnerGallery.prototype.showImages = function(images) {
|
26
|
+
return $.facybox({
|
27
|
+
images: images
|
28
|
+
});
|
29
|
+
};
|
30
|
+
|
31
|
+
ns.galleries = {};
|
32
|
+
ns.create = function(name, selector) {
|
33
|
+
var gallery;
|
34
|
+
gallery = new InnerGallery(selector);
|
35
|
+
ns.galleries[name] = gallery;
|
36
|
+
return gallery;
|
37
|
+
};
|
38
|
+
ns.get = function(name) {
|
39
|
+
return ns.galleries[name];
|
40
|
+
};
|
41
|
+
return ns.get;
|
42
|
+
});
|
data/lib/youthtree-js.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{youthtree-js}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Darcy Laycock"]
|
12
|
+
s.date = %q{2010-06-12}
|
13
|
+
s.description = %q{Shared Javascript tools across YouthTree apps.}
|
14
|
+
s.email = %q{sutto@sutto.net}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"coffeescripts/youth_tree.coffee",
|
22
|
+
"coffeescripts/youth_tree/gallery.coffee",
|
23
|
+
"javascripts/youth_tree.js",
|
24
|
+
"javascripts/youth_tree/gallery.js",
|
25
|
+
"lib/youthtree-js.rb",
|
26
|
+
"youthtree-js.gemspec"
|
27
|
+
]
|
28
|
+
s.homepage = %q{http://github.com/YouthTree/youthtree-js}
|
29
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
s.rubygems_version = %q{1.3.7}
|
32
|
+
s.summary = %q{Shared Javascript tools across YouthTree apps.}
|
33
|
+
|
34
|
+
if s.respond_to? :specification_version then
|
35
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
36
|
+
s.specification_version = 3
|
37
|
+
|
38
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
39
|
+
else
|
40
|
+
end
|
41
|
+
else
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: youthtree-js
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Darcy Laycock
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-12 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Shared Javascript tools across YouthTree apps.
|
23
|
+
email: sutto@sutto.net
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.md
|
30
|
+
files:
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- coffeescripts/youth_tree.coffee
|
34
|
+
- coffeescripts/youth_tree/gallery.coffee
|
35
|
+
- javascripts/youth_tree.js
|
36
|
+
- javascripts/youth_tree/gallery.js
|
37
|
+
- lib/youthtree-js.rb
|
38
|
+
- youthtree-js.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/YouthTree/youthtree-js
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Shared Javascript tools across YouthTree apps.
|
73
|
+
test_files: []
|
74
|
+
|