fancybox2-rails 0.2.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.
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +61 -0
- data/Rakefile +65 -0
- data/lib/fancybox2-rails.rb +3 -0
- data/lib/fancybox2/rails.rb +2 -0
- data/lib/fancybox2/rails/engine.rb +6 -0
- data/lib/fancybox2/rails/version.rb +6 -0
- data/vendor/assets/images/blank.gif +0 -0
- data/vendor/assets/images/fancybox_buttons.png +0 -0
- data/vendor/assets/images/fancybox_loading.gif +0 -0
- data/vendor/assets/images/fancybox_overlay.png +0 -0
- data/vendor/assets/images/fancybox_sprite.png +0 -0
- data/vendor/assets/javascripts/fancybox.js +4 -0
- data/vendor/assets/javascripts/jquery.fancybox-buttons.js +120 -0
- data/vendor/assets/javascripts/jquery.fancybox-media.js +196 -0
- data/vendor/assets/javascripts/jquery.fancybox-thumbs.js +164 -0
- data/vendor/assets/javascripts/jquery.fancybox.js +1912 -0
- data/vendor/assets/stylesheets/fancybox.css +5 -0
- data/vendor/assets/stylesheets/jquery.fancybox-buttons.css.erb +96 -0
- data/vendor/assets/stylesheets/jquery.fancybox-thumbs.css +54 -0
- data/vendor/assets/stylesheets/jquery.fancybox.css.erb +246 -0
- metadata +138 -0
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Chris Mytton
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
fancybox2-rails
|
2
|
+
==============
|
3
|
+
|
4
|
+
Use [fancybox](http://www.fancyapps.com/fancybox/) with rails 3.1 asset pipeline.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
This gem vendors jquery fancybox 2 for Rails 3.1 and greater. The files
|
9
|
+
will be added to the asset pipeline and available for you to use.
|
10
|
+
|
11
|
+
First add the following lines to your applications `Gemfile`:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem 'jquery-rails'
|
15
|
+
gem 'fancybox2-rails'
|
16
|
+
```
|
17
|
+
|
18
|
+
Then run `bundle install` to update your application's bundle.
|
19
|
+
|
20
|
+
Now you need to edit your `app/assets/javascripts/application.js`
|
21
|
+
file and add the following line:
|
22
|
+
|
23
|
+
``` javascript
|
24
|
+
//= require jquery
|
25
|
+
//= require fancybox
|
26
|
+
```
|
27
|
+
|
28
|
+
And then edit your `app/assets/stylesheets/application.css` file to
|
29
|
+
look something like:
|
30
|
+
|
31
|
+
``` css
|
32
|
+
/*
|
33
|
+
*= require_self
|
34
|
+
*= require fancybox
|
35
|
+
*= require_tree .
|
36
|
+
*/
|
37
|
+
```
|
38
|
+
|
39
|
+
That's it!
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
With the gem installed and included in your asset manifests, you can now
|
44
|
+
use fancybox as you normally would.
|
45
|
+
|
46
|
+
``` javascript
|
47
|
+
$(document).ready(function() {
|
48
|
+
$("a.fancybox").fancybox();
|
49
|
+
});
|
50
|
+
```
|
51
|
+
|
52
|
+
## More information
|
53
|
+
|
54
|
+
* [Contributors](https://github.com/hecticjeff/fancybox-rails/contributors)
|
55
|
+
* [DHH's RailsConf 2011 talk on the rails 3.1 asset pipeline](http://www.youtube.com/watch?v=cGdCI2HhfAU)
|
56
|
+
|
57
|
+
Copyright (c) Chris Mytton
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
[Fancybox 2 license](http://www.fancyapps.com/fancybox/#license)
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
# For checking remote fancybox version.
|
9
|
+
require 'nokogiri'
|
10
|
+
require 'open-uri'
|
11
|
+
|
12
|
+
# Path to atom feed with fancybox updates.
|
13
|
+
$fancybox_feed = "http://code.google.com/feeds/p/fancybox/downloads/basic"
|
14
|
+
|
15
|
+
Bundler::GemHelper.install_tasks
|
16
|
+
|
17
|
+
require 'rake/testtask'
|
18
|
+
|
19
|
+
Rake::TestTask.new(:test) do |t|
|
20
|
+
t.libs << 'lib'
|
21
|
+
t.libs << 'test'
|
22
|
+
t.pattern = 'test/**/*_test.rb'
|
23
|
+
t.verbose = false
|
24
|
+
end
|
25
|
+
|
26
|
+
task :default => :test
|
27
|
+
|
28
|
+
namespace :fancybox do
|
29
|
+
desc "Get the local and remote fancybox versions."
|
30
|
+
task :version do
|
31
|
+
local = local_version
|
32
|
+
remote = remote_version
|
33
|
+
|
34
|
+
puts "local: v#{local}"
|
35
|
+
puts "remote: v#{remote}"
|
36
|
+
|
37
|
+
if local != remote
|
38
|
+
warn "\nthere is a newer remote version available"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get the current local version of the vendored fancybox library.
|
44
|
+
#
|
45
|
+
# Returns the String representing the local version.
|
46
|
+
def local_version
|
47
|
+
`grep ' * Version' vendor/assets/javascripts/jquery.fancybox.js | \
|
48
|
+
cut -d ' ' -f 4`.chomp
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get the current version of the remote version of the library. Uses
|
52
|
+
# nokogiri and open-uri to grab the atom feed from google code, then
|
53
|
+
# parses the version out of the title.
|
54
|
+
#
|
55
|
+
# Returns the String representing the remote version.
|
56
|
+
def remote_version
|
57
|
+
doc = Nokogiri::HTML(open($fancybox_feed))
|
58
|
+
doc.css('entry:first title').text.match(/\d\.\d\.\d/)[0]
|
59
|
+
end
|
60
|
+
|
61
|
+
task :travis do
|
62
|
+
puts "Starting to run rake travis"
|
63
|
+
system("export DISPLAY=:99.0 && bundle exec rake")
|
64
|
+
raise "rake travis failed!" unless $?.exitstatus == 0
|
65
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,120 @@
|
|
1
|
+
/*!
|
2
|
+
* Buttons helper for fancyBox
|
3
|
+
* version: 1.0.3
|
4
|
+
* @requires fancyBox v2.0 or later
|
5
|
+
*
|
6
|
+
* Usage:
|
7
|
+
* $(".fancybox").fancybox({
|
8
|
+
* helpers : {
|
9
|
+
* buttons: {
|
10
|
+
* position : 'top'
|
11
|
+
* }
|
12
|
+
* }
|
13
|
+
* });
|
14
|
+
*
|
15
|
+
* Options:
|
16
|
+
* tpl - HTML template
|
17
|
+
* position - 'top' or 'bottom'
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
(function ($) {
|
21
|
+
//Shortcut for fancyBox object
|
22
|
+
var F = $.fancybox;
|
23
|
+
|
24
|
+
//Add helper object
|
25
|
+
F.helpers.buttons = {
|
26
|
+
tpl : '<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="Previous" href="javascript:;"></a></li><li><a class="btnPlay" title="Start slideshow" href="javascript:;"></a></li><li><a class="btnNext" title="Next" href="javascript:;"></a></li><li><a class="btnToggle" title="Toggle size" href="javascript:;"></a></li><li><a class="btnClose" title="Close" href="javascript:jQuery.fancybox.close();"></a></li></ul></div>',
|
27
|
+
list : null,
|
28
|
+
buttons: null,
|
29
|
+
|
30
|
+
beforeLoad: function (opts, obj) {
|
31
|
+
//Remove self if gallery do not have at least two items
|
32
|
+
|
33
|
+
if (opts.skipSingle && obj.group.length < 2) {
|
34
|
+
obj.helpers.buttons = false;
|
35
|
+
obj.closeBtn = true;
|
36
|
+
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
|
40
|
+
//Increase top margin to give space for buttons
|
41
|
+
obj.margin[ opts.position === 'bottom' ? 2 : 0 ] += 30;
|
42
|
+
},
|
43
|
+
|
44
|
+
onPlayStart: function () {
|
45
|
+
if (this.buttons) {
|
46
|
+
this.buttons.play.attr('title', 'Pause slideshow').addClass('btnPlayOn');
|
47
|
+
}
|
48
|
+
},
|
49
|
+
|
50
|
+
onPlayEnd: function () {
|
51
|
+
if (this.buttons) {
|
52
|
+
this.buttons.play.attr('title', 'Start slideshow').removeClass('btnPlayOn');
|
53
|
+
}
|
54
|
+
},
|
55
|
+
|
56
|
+
afterShow: function (opts, obj) {
|
57
|
+
var buttons = this.buttons;
|
58
|
+
|
59
|
+
if (!buttons) {
|
60
|
+
this.list = $(opts.tpl || this.tpl).addClass(opts.position || 'top').appendTo('body');
|
61
|
+
|
62
|
+
buttons = {
|
63
|
+
prev : this.list.find('.btnPrev').click( F.prev ),
|
64
|
+
next : this.list.find('.btnNext').click( F.next ),
|
65
|
+
play : this.list.find('.btnPlay').click( F.play ),
|
66
|
+
toggle : this.list.find('.btnToggle').click( F.toggle )
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
//Prev
|
71
|
+
if (obj.index > 0 || obj.loop) {
|
72
|
+
buttons.prev.removeClass('btnDisabled');
|
73
|
+
} else {
|
74
|
+
buttons.prev.addClass('btnDisabled');
|
75
|
+
}
|
76
|
+
|
77
|
+
//Next / Play
|
78
|
+
if (obj.loop || obj.index < obj.group.length - 1) {
|
79
|
+
buttons.next.removeClass('btnDisabled');
|
80
|
+
buttons.play.removeClass('btnDisabled');
|
81
|
+
|
82
|
+
} else {
|
83
|
+
buttons.next.addClass('btnDisabled');
|
84
|
+
buttons.play.addClass('btnDisabled');
|
85
|
+
}
|
86
|
+
|
87
|
+
this.buttons = buttons;
|
88
|
+
|
89
|
+
this.onUpdate(opts, obj);
|
90
|
+
},
|
91
|
+
|
92
|
+
onUpdate: function (opts, obj) {
|
93
|
+
var toggle;
|
94
|
+
|
95
|
+
if (!this.buttons) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
|
99
|
+
toggle = this.buttons.toggle.removeClass('btnDisabled btnToggleOn');
|
100
|
+
|
101
|
+
//Size toggle button
|
102
|
+
if (obj.canShrink) {
|
103
|
+
toggle.addClass('btnToggleOn');
|
104
|
+
|
105
|
+
} else if (!obj.canExpand) {
|
106
|
+
toggle.addClass('btnDisabled');
|
107
|
+
}
|
108
|
+
},
|
109
|
+
|
110
|
+
beforeClose: function () {
|
111
|
+
if (this.list) {
|
112
|
+
this.list.remove();
|
113
|
+
}
|
114
|
+
|
115
|
+
this.list = null;
|
116
|
+
this.buttons = null;
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
}(jQuery));
|
@@ -0,0 +1,196 @@
|
|
1
|
+
/*!
|
2
|
+
* Media helper for fancyBox
|
3
|
+
* version: 1.0.3 (Mon, 13 Aug 2012)
|
4
|
+
* @requires fancyBox v2.0 or later
|
5
|
+
*
|
6
|
+
* Usage:
|
7
|
+
* $(".fancybox").fancybox({
|
8
|
+
* helpers : {
|
9
|
+
* media: true
|
10
|
+
* }
|
11
|
+
* });
|
12
|
+
*
|
13
|
+
* Set custom URL parameters:
|
14
|
+
* $(".fancybox").fancybox({
|
15
|
+
* helpers : {
|
16
|
+
* media: {
|
17
|
+
* youtube : {
|
18
|
+
* params : {
|
19
|
+
* autoplay : 0
|
20
|
+
* }
|
21
|
+
* }
|
22
|
+
* }
|
23
|
+
* }
|
24
|
+
* });
|
25
|
+
*
|
26
|
+
* Or:
|
27
|
+
* $(".fancybox").fancybox({,
|
28
|
+
* helpers : {
|
29
|
+
* media: true
|
30
|
+
* },
|
31
|
+
* youtube : {
|
32
|
+
* autoplay: 0
|
33
|
+
* }
|
34
|
+
* });
|
35
|
+
*
|
36
|
+
* Supports:
|
37
|
+
*
|
38
|
+
* Youtube
|
39
|
+
* http://www.youtube.com/watch?v=opj24KnzrWo
|
40
|
+
* http://youtu.be/opj24KnzrWo
|
41
|
+
* Vimeo
|
42
|
+
* http://vimeo.com/40648169
|
43
|
+
* http://vimeo.com/channels/staffpicks/38843628
|
44
|
+
* http://vimeo.com/groups/surrealism/videos/36516384
|
45
|
+
* http://player.vimeo.com/video/45074303
|
46
|
+
* Metacafe
|
47
|
+
* http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/
|
48
|
+
* http://www.metacafe.com/watch/7635964/
|
49
|
+
* Dailymotion
|
50
|
+
* http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people
|
51
|
+
* Twitvid
|
52
|
+
* http://twitvid.com/QY7MD
|
53
|
+
* Twitpic
|
54
|
+
* http://twitpic.com/7p93st
|
55
|
+
* Instagram
|
56
|
+
* http://instagr.am/p/IejkuUGxQn/
|
57
|
+
* http://instagram.com/p/IejkuUGxQn/
|
58
|
+
* Google maps
|
59
|
+
* http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17
|
60
|
+
* http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16
|
61
|
+
* http://maps.google.com/?ll=48.859463,2.292626&spn=0.000965,0.002642&t=m&z=19&layer=c&cbll=48.859524,2.292532&panoid=YJ0lq28OOy3VT2IqIuVY0g&cbp=12,151.58,,0,-15.56
|
62
|
+
*/
|
63
|
+
(function ($) {
|
64
|
+
"use strict";
|
65
|
+
|
66
|
+
//Shortcut for fancyBox object
|
67
|
+
var F = $.fancybox,
|
68
|
+
format = function( url, rez, params ) {
|
69
|
+
params = params || '';
|
70
|
+
|
71
|
+
if ( $.type( params ) === "object" ) {
|
72
|
+
params = $.param(params, true);
|
73
|
+
}
|
74
|
+
|
75
|
+
$.each(rez, function(key, value) {
|
76
|
+
url = url.replace( '$' + key, value || '' );
|
77
|
+
});
|
78
|
+
|
79
|
+
if (params.length) {
|
80
|
+
url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params;
|
81
|
+
}
|
82
|
+
|
83
|
+
return url;
|
84
|
+
};
|
85
|
+
|
86
|
+
//Add helper object
|
87
|
+
F.helpers.media = {
|
88
|
+
types : {
|
89
|
+
youtube : {
|
90
|
+
matcher : /(youtube\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed)?([\w-]{11}|\?listType=(.*)&list=(.*)).*/i,
|
91
|
+
params : {
|
92
|
+
autoplay : 1,
|
93
|
+
autohide : 1,
|
94
|
+
fs : 1,
|
95
|
+
rel : 0,
|
96
|
+
hd : 1,
|
97
|
+
wmode : 'opaque',
|
98
|
+
enablejsapi : 1
|
99
|
+
},
|
100
|
+
type : 'iframe',
|
101
|
+
url : '//www.youtube.com/embed/$3'
|
102
|
+
},
|
103
|
+
vimeo : {
|
104
|
+
matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/,
|
105
|
+
params : {
|
106
|
+
autoplay : 1,
|
107
|
+
hd : 1,
|
108
|
+
show_title : 1,
|
109
|
+
show_byline : 1,
|
110
|
+
show_portrait : 0,
|
111
|
+
color : '',
|
112
|
+
fullscreen : 1
|
113
|
+
},
|
114
|
+
type : 'iframe',
|
115
|
+
url : '//player.vimeo.com/video/$1'
|
116
|
+
},
|
117
|
+
metacafe : {
|
118
|
+
matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/,
|
119
|
+
params : {
|
120
|
+
autoPlay : 'yes'
|
121
|
+
},
|
122
|
+
type : 'swf',
|
123
|
+
url : function( rez, params, obj ) {
|
124
|
+
obj.swf.flashVars = 'playerVars=' + $.param( params, true );
|
125
|
+
|
126
|
+
return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf';
|
127
|
+
}
|
128
|
+
},
|
129
|
+
dailymotion : {
|
130
|
+
matcher : /dailymotion.com\/video\/(.*)\/?(.*)/,
|
131
|
+
params : {
|
132
|
+
additionalInfos : 0,
|
133
|
+
autoStart : 1
|
134
|
+
},
|
135
|
+
type : 'swf',
|
136
|
+
url : '//www.dailymotion.com/swf/video/$1'
|
137
|
+
},
|
138
|
+
twitvid : {
|
139
|
+
matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i,
|
140
|
+
params : {
|
141
|
+
autoplay : 0
|
142
|
+
},
|
143
|
+
type : 'iframe',
|
144
|
+
url : '//www.twitvid.com/embed.php?guid=$1'
|
145
|
+
},
|
146
|
+
twitpic : {
|
147
|
+
matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i,
|
148
|
+
type : 'image',
|
149
|
+
url : '//twitpic.com/show/full/$1/'
|
150
|
+
},
|
151
|
+
instagram : {
|
152
|
+
matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i,
|
153
|
+
type : 'image',
|
154
|
+
url : '//$1/p/$2/media/'
|
155
|
+
},
|
156
|
+
google_maps : {
|
157
|
+
matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i,
|
158
|
+
type : 'iframe',
|
159
|
+
url : function( rez ) {
|
160
|
+
return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed');
|
161
|
+
}
|
162
|
+
}
|
163
|
+
},
|
164
|
+
|
165
|
+
beforeLoad : function(opts, obj) {
|
166
|
+
var url = obj.href || '',
|
167
|
+
type = false,
|
168
|
+
what,
|
169
|
+
item,
|
170
|
+
rez,
|
171
|
+
params;
|
172
|
+
|
173
|
+
for (what in this.types) {
|
174
|
+
item = this.types[ what ];
|
175
|
+
rez = url.match( item.matcher );
|
176
|
+
|
177
|
+
if (rez) {
|
178
|
+
type = item.type;
|
179
|
+
params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null));
|
180
|
+
|
181
|
+
url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params );
|
182
|
+
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
if (type) {
|
188
|
+
obj.href = url;
|
189
|
+
obj.type = type;
|
190
|
+
|
191
|
+
obj.autoHeight = false;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
};
|
195
|
+
|
196
|
+
}(jQuery));
|