carousel 1.0.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/LICENSE.txt +20 -0
- data/README.md +117 -0
- data/carousel.gemspec +71 -0
- data/lib/carousel.rb +40 -0
- data/lib/carousel/paperclip/round_corners.rb +61 -0
- data/vendor/assets/images/lightbox/blank.gif +0 -0
- data/vendor/assets/images/lightbox/close.gif +0 -0
- data/vendor/assets/images/lightbox/loading.gif +0 -0
- data/vendor/assets/images/lightbox/next.gif +0 -0
- data/vendor/assets/images/lightbox/prev.gif +0 -0
- data/vendor/assets/javascripts/carousel.js.coffee.erb +84 -0
- data/vendor/assets/javascripts/jquery.lightbox-0.5.js +498 -0
- data/vendor/assets/stylesheets/carousel.css.scss +35 -0
- data/vendor/assets/stylesheets/jquery.lightbox-0.5.css +101 -0
- metadata +177 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Tim Morgan
|
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,117 @@
|
|
1
|
+
Carousel
|
2
|
+
========
|
3
|
+
|
4
|
+
A Ruby on Rails engine that adds an image carousel to your application.
|
5
|
+
|
6
|
+
| | |
|
7
|
+
|:------------|:--------------------------------------------------------------------------------------------------------|
|
8
|
+
| **Author** | Tim Morgan |
|
9
|
+
| **Version** | 1.0 (Apr 20, 2012) |
|
10
|
+
| **License** | Released under the MIT license. Portions released under a different license (see _Sub-Licenses_ below). |
|
11
|
+
|
12
|
+
About
|
13
|
+
-----
|
14
|
+
|
15
|
+
This gem adds assets to your Rails application allowing you to display a simple
|
16
|
+
but effective carousel of images. The carousel can be displayed horizontally or
|
17
|
+
vertically. It uses Ajax to incrementally load images rather than loading them
|
18
|
+
all at once.
|
19
|
+
|
20
|
+
### Requirements
|
21
|
+
|
22
|
+
* **Rails 3.1**: This gem uses Rails engines.
|
23
|
+
* **jQuery**: The carousel and lightbox is rendered and managed using jQuery.
|
24
|
+
* **Sass**: The carousel layout is written using SCSS.
|
25
|
+
|
26
|
+
#### Optional
|
27
|
+
|
28
|
+
* **Paperclip**: The carousel includes native support for Paperclip, but does
|
29
|
+
not depend on it.
|
30
|
+
|
31
|
+
Installation
|
32
|
+
------------
|
33
|
+
|
34
|
+
To use this gem, add to your Gemfile:
|
35
|
+
|
36
|
+
```` ruby
|
37
|
+
gem 'carousel'
|
38
|
+
````
|
39
|
+
|
40
|
+
To your `application.css` file (or some other CSS manifest file), add:
|
41
|
+
|
42
|
+
```` css
|
43
|
+
/*
|
44
|
+
*= require jquery.lightbox-0.5
|
45
|
+
*= require carousel
|
46
|
+
*/
|
47
|
+
````
|
48
|
+
|
49
|
+
To your `application.js` file (or some other JavaScript manifest file), add:
|
50
|
+
|
51
|
+
```` javascript
|
52
|
+
//= require jquery.lightbox-0.5
|
53
|
+
//= require carousel
|
54
|
+
````
|
55
|
+
|
56
|
+
You may also need to add the following if it is not already there:
|
57
|
+
|
58
|
+
```` javascript
|
59
|
+
//= require jquery
|
60
|
+
````
|
61
|
+
|
62
|
+
Usage
|
63
|
+
-----
|
64
|
+
|
65
|
+
The carousel loads images using an Ajax action. You will need to write such an
|
66
|
+
action that returns JSON information about the images the carousel should load
|
67
|
+
in an "infinite scrolling" manner. The JSON should have the format shown in the
|
68
|
+
following example:
|
69
|
+
|
70
|
+
```` json
|
71
|
+
[
|
72
|
+
{
|
73
|
+
"caption": "Parents' house from the air",
|
74
|
+
"id": 26,
|
75
|
+
"preview_url": "http://s3.amazonaws.com/flightseein/photographs/26/images/carousel-ac52ff7c1f101e9fe86b1bbe0c7e8dab.png",
|
76
|
+
"url": "http://s3.amazonaws.com/flightseein/photographs/26/images/original-ac52ff7c1f101e9fe86b1bbe0c7e8dab.jpeg"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"caption": "Mt. Diablo",
|
80
|
+
"id": 27,
|
81
|
+
"preview_url": "http://s3.amazonaws.com/flightseein/photographs/27/images/carousel-9bcf168a861a840be7cdd2914bb3e539.png",
|
82
|
+
"url": "http://s3.amazonaws.com/flightseein/photographs/27/images/original-9bcf168a861a840be7cdd2914bb3e539.jpeg"
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"caption": "UC Berkeley",
|
86
|
+
"id": 28,
|
87
|
+
"preview_url": "http://s3.amazonaws.com/flightseein/photographs/28/images/carousel-663d4602da82c6b2bd0f88cd5be2da7d.png",
|
88
|
+
"url": "http://s3.amazonaws.com/flightseein/photographs/28/images/original-663d4602da82c6b2bd0f88cd5be2da7d.jpeg"
|
89
|
+
}
|
90
|
+
]
|
91
|
+
````
|
92
|
+
|
93
|
+
All fields are required except for `caption`.
|
94
|
+
|
95
|
+
Your controller should also correctly manage the infinite-scrolling feature by
|
96
|
+
accepting a parameter `last_record`. This parameter will be the ID of the last
|
97
|
+
photo previously loaded. You should load the next group of photos from that ID.
|
98
|
+
What you define "ID" as, and how you order the photos, and how many photos you
|
99
|
+
include in a batch, are all up to you.
|
100
|
+
|
101
|
+
In your view, instantiate a Carousel object like so:
|
102
|
+
|
103
|
+
```` javascript+erb
|
104
|
+
$('#carousel-container').carousel("<%= photographs_url %>", 'horizontal');
|
105
|
+
````
|
106
|
+
|
107
|
+
where `$('#carousel-container')` is the jQuery-wrapped DOM element to contain
|
108
|
+
the carousel, and `photographs_url` is the URL endpoint for the controller you
|
109
|
+
wrote above. The second parameter can be either `horizontal` or `vertical` and
|
110
|
+
describes the orientation of your carousel.
|
111
|
+
|
112
|
+
Sub-Licenses
|
113
|
+
------------
|
114
|
+
|
115
|
+
Portions of this code were written by
|
116
|
+
"Leandro Vieira Pinho":http://leandrovieira.com. These portions are distributed
|
117
|
+
under the CCAttribution-Share-Alike 2.5 (Brazil) license.
|
data/carousel.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "carousel"
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tim Morgan"]
|
12
|
+
s.date = "2012-04-20"
|
13
|
+
s.description = "Adds CoffeeScript and SCSS files to your Rails apps allowing you to easily create an Ajax-powered Carousel."
|
14
|
+
s.email = "rubygems@timothymorgan.info"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"LICENSE.txt",
|
21
|
+
"README.md",
|
22
|
+
"carousel.gemspec",
|
23
|
+
"lib/carousel.rb",
|
24
|
+
"lib/carousel/paperclip/round_corners.rb",
|
25
|
+
"vendor/assets/images/lightbox/blank.gif",
|
26
|
+
"vendor/assets/images/lightbox/close.gif",
|
27
|
+
"vendor/assets/images/lightbox/loading.gif",
|
28
|
+
"vendor/assets/images/lightbox/next.gif",
|
29
|
+
"vendor/assets/images/lightbox/prev.gif",
|
30
|
+
"vendor/assets/javascripts/carousel.js.coffee.erb",
|
31
|
+
"vendor/assets/javascripts/jquery.lightbox-0.5.js",
|
32
|
+
"vendor/assets/stylesheets/carousel.css.scss",
|
33
|
+
"vendor/assets/stylesheets/jquery.lightbox-0.5.css"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/RISCfuture/carousel"
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = "1.8.21"
|
39
|
+
s.summary = "Simple image carousels in your Rails apps."
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<compass>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<jquery-rails>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<paperclip>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
54
|
+
s.add_dependency(%q<compass>, [">= 0"])
|
55
|
+
s.add_dependency(%q<jquery-rails>, [">= 0"])
|
56
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
57
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
58
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
59
|
+
s.add_dependency(%q<paperclip>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
63
|
+
s.add_dependency(%q<compass>, [">= 0"])
|
64
|
+
s.add_dependency(%q<jquery-rails>, [">= 0"])
|
65
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
66
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
67
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
68
|
+
s.add_dependency(%q<paperclip>, [">= 0"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
data/lib/carousel.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'carousel/paperclip/round_corners' if defined?(Paperclip)
|
2
|
+
|
3
|
+
# Rails engine for the Carousel plug-in.
|
4
|
+
|
5
|
+
class Carousel < Rails::Engine
|
6
|
+
|
7
|
+
# Returns options for the `has_attached_file` method to include a
|
8
|
+
# Carousel-compatible style. You can override any options as necessary using
|
9
|
+
# `additional`.
|
10
|
+
#
|
11
|
+
# @example Basic example with additional styles
|
12
|
+
# has_attached_file Carousel.paperclip_options(
|
13
|
+
# styles: {
|
14
|
+
# another: '512x512'
|
15
|
+
# }
|
16
|
+
# )
|
17
|
+
#
|
18
|
+
# @example Overriding carousel border radius
|
19
|
+
# has_attached_file Carousel.paperclip_options(
|
20
|
+
# styles: { carousel: { border_radius: 5 } }
|
21
|
+
# )
|
22
|
+
#
|
23
|
+
# @param [Hash] additional Additional styles or other Paperclip options to
|
24
|
+
# pass to `has_attached_file`, or overrides for the options this method adds
|
25
|
+
# (see the source).
|
26
|
+
# @return [Hash] Options to pass to `has_attached_file`.
|
27
|
+
|
28
|
+
def self.paperclip_options(additional={})
|
29
|
+
additional[:processors] = Array.wrap(additional[:processors])
|
30
|
+
additional[:processors] << :round_corners
|
31
|
+
|
32
|
+
additional[:styles] ||= {}
|
33
|
+
additional[:styles][:carousel] ||= {}
|
34
|
+
additional[:styles][:carousel][:geometry] ||= '140x100#'
|
35
|
+
additional[:styles][:carousel][:format] ||= :png
|
36
|
+
additional[:styles][:carousel][:border_radius] ||= 8
|
37
|
+
|
38
|
+
additional
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Paperclip
|
2
|
+
|
3
|
+
# Paperclip processor that uses ImageMagick to create rounded corners.
|
4
|
+
#
|
5
|
+
# Derived from https://github.com/kerinin/paperclip-rounded-corners
|
6
|
+
|
7
|
+
class RoundCorners < Paperclip::Thumbnail
|
8
|
+
# @private
|
9
|
+
def parse_opts(key)
|
10
|
+
opt = @options[:border_radius]
|
11
|
+
opt.nil? ? nil : opt.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String] The ImageMagick command that rounds an image's corners.
|
15
|
+
|
16
|
+
def transformation
|
17
|
+
trans = " \\( +clone -threshold -1 "
|
18
|
+
trans << "-draw 'fill black polygon 0,0 0,#{@radius} #{@radius},0 fill white circle #{@radius},#{@radius} #{@radius},0' "
|
19
|
+
trans << "\\( +clone -flip \\) -compose Multiply -composite "
|
20
|
+
trans << "\\( +clone -flop \\) -compose Multiply -composite "
|
21
|
+
trans << "\\) +matte -compose CopyOpacity -composite "
|
22
|
+
trans
|
23
|
+
end
|
24
|
+
|
25
|
+
# Performs the ImageMagick corner-roundage.
|
26
|
+
#
|
27
|
+
# @param [Paperclip::Attachment] dst The Paperclip image.
|
28
|
+
# @return [Paperclip::Attachment] `dst`.
|
29
|
+
|
30
|
+
def round_corners(dst)
|
31
|
+
command = "\"#{ File.expand_path(@thumbnail.path) }[0]\" #{ transformation } \"#{ File.expand_path(dst.path) }\""
|
32
|
+
Paperclip.run('convert', command)
|
33
|
+
dst
|
34
|
+
end
|
35
|
+
|
36
|
+
# @private
|
37
|
+
def initialize(file, options = { }, attachment = nil)
|
38
|
+
super file, options, attachment
|
39
|
+
|
40
|
+
@radius = options[:border_radius]
|
41
|
+
@process = @radius
|
42
|
+
end
|
43
|
+
|
44
|
+
# @private
|
45
|
+
def make
|
46
|
+
@thumbnail = super
|
47
|
+
|
48
|
+
if @process
|
49
|
+
@width = Paperclip::Geometry.from_file(@thumbnail).width.to_i
|
50
|
+
@height = Paperclip::Geometry.from_file(@thumbnail).height.to_i
|
51
|
+
|
52
|
+
dst = Tempfile.new([@basename, @format].compact.join("."))
|
53
|
+
dst.binmode
|
54
|
+
|
55
|
+
return round_corners(dst)
|
56
|
+
else
|
57
|
+
return @thumbnail
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class Carousel
|
2
|
+
constructor: (@element, @url, @orientation, @options={}) ->
|
3
|
+
@options = $.extend({ captions: true, lightboxes: true }, @options)
|
4
|
+
@element.addClass "carousel-#{@orientation}"
|
5
|
+
@data = []
|
6
|
+
|
7
|
+
this.refresh()
|
8
|
+
this.setScroll()
|
9
|
+
|
10
|
+
refresh: ->
|
11
|
+
this.clear()
|
12
|
+
$.ajax @url,
|
13
|
+
dataType: 'json',
|
14
|
+
error: (xhr, status, error) =>
|
15
|
+
this.setError "Couldn't load photos: #{if status == 'error' then error else status}."
|
16
|
+
success: (data) =>
|
17
|
+
this.populate data
|
18
|
+
|
19
|
+
clear: ->
|
20
|
+
@element.find('>li').remove()
|
21
|
+
@data = []
|
22
|
+
|
23
|
+
populate: (data) ->
|
24
|
+
@data = @data.concat(data) # must clone it
|
25
|
+
|
26
|
+
if @data.length == 0
|
27
|
+
this.setNote "No photos yet."
|
28
|
+
return
|
29
|
+
|
30
|
+
$.each data, (_, photo) =>
|
31
|
+
li = $('<li/>').appendTo(@element)
|
32
|
+
fig = $('<figure/>').appendTo(li)
|
33
|
+
a = $('<a/>').attr(href: photo.url, title: photo.caption).appendTo(fig)
|
34
|
+
$('<img/>').attr('src', photo.preview_url).appendTo a
|
35
|
+
$('<figcaption/>').text(photo.caption).appendTo(fig) if @options['captions'] and photo.caption
|
36
|
+
|
37
|
+
if @options['lightboxes']
|
38
|
+
@element.find('a').lightBox
|
39
|
+
imageLoading: '<%= image_path "lightbox/loading.gif" %>'
|
40
|
+
imageBtnClose: '<%= image_path "lightbox/close.gif" %>'
|
41
|
+
imageBtnPrev: '<%= image_path "lightbox/prev.gif" %>'
|
42
|
+
imageBtnNext: '<%= image_path "lightbox/next.gif" %>'
|
43
|
+
imageBlank: '<%= image_path "lightbox/blank.gif" %>'
|
44
|
+
txtImage: ''
|
45
|
+
|
46
|
+
this.loadNextPage() if this.noScroll() and data.length > 0
|
47
|
+
|
48
|
+
setError: (error) ->
|
49
|
+
this.clear()
|
50
|
+
li = $('<li/>').addClass('center').appendTo @element
|
51
|
+
$('<p/>').addClass('error').text(error).appendTo li
|
52
|
+
|
53
|
+
setNote: (note) ->
|
54
|
+
this.clear()
|
55
|
+
li = $('<li/>').addClass('center').appendTo @element
|
56
|
+
$('<p/>').addClass('note').text(note).appendTo li
|
57
|
+
|
58
|
+
setScroll: ->
|
59
|
+
@element.scroll =>
|
60
|
+
this.loadNextPage() if this.isAtEnd()
|
61
|
+
|
62
|
+
noScroll: ->
|
63
|
+
switch @orientation
|
64
|
+
when 'horizontal' then @element.width() == @element[0].scrollWidth
|
65
|
+
when 'vertical' then @element.height() == @element[0].scrollHeight
|
66
|
+
|
67
|
+
isAtEnd: ->
|
68
|
+
switch @orientation
|
69
|
+
when 'horizontal' then @element.scrollLeft() == @element[0].scrollWidth - @element.width()
|
70
|
+
when 'vertical' then @element.scrollTop() == @element[0].scrollheight - @element.height()
|
71
|
+
|
72
|
+
loadNextPage: ->
|
73
|
+
return if @data.length == 0
|
74
|
+
$.ajax @url,
|
75
|
+
data: { last_record: @data[@data.length - 1].id }
|
76
|
+
dataType: 'json'
|
77
|
+
error: (xhr, status, error) =>
|
78
|
+
this.setError "Couldn't load photos: #{if status == 'error' then error else status}."
|
79
|
+
success: (data) =>
|
80
|
+
this.populate data
|
81
|
+
|
82
|
+
$.fn.extend
|
83
|
+
carousel: (url, orient, options={}) ->
|
84
|
+
new Carousel(this, url, orient, options)
|
@@ -0,0 +1,498 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery lightBox plugin
|
3
|
+
* This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
|
4
|
+
* and adapted to me for use like a plugin from jQuery.
|
5
|
+
* @name jquery-lightbox-0.5.js
|
6
|
+
* @author Leandro Vieira Pinho - http://leandrovieira.com
|
7
|
+
* @version 0.5
|
8
|
+
* @date April 11, 2008
|
9
|
+
* @category jQuery plugin
|
10
|
+
* @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
|
11
|
+
* @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
|
12
|
+
* @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
|
13
|
+
*/
|
14
|
+
|
15
|
+
// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
|
16
|
+
(function($) {
|
17
|
+
/**
|
18
|
+
* $ is an alias to jQuery object
|
19
|
+
*
|
20
|
+
*/
|
21
|
+
$.fn.lightBox = function(settings) {
|
22
|
+
// Settings to configure the jQuery lightBox plugin how you like
|
23
|
+
settings = jQuery.extend({
|
24
|
+
// Configuration related to overlay
|
25
|
+
overlayBgColor: '#000', // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
|
26
|
+
overlayOpacity: 0.8, // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
|
27
|
+
// Configuration related to navigation
|
28
|
+
fixedNavigation: false, // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
|
29
|
+
// Configuration related to images
|
30
|
+
imageLoading: 'images/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
|
31
|
+
imageBtnPrev: 'images/lightbox-btn-prev.gif', // (string) Path and the name of the prev button image
|
32
|
+
imageBtnNext: 'images/lightbox-btn-next.gif', // (string) Path and the name of the next button image
|
33
|
+
imageBtnClose: 'images/lightbox-btn-close.gif', // (string) Path and the name of the close btn
|
34
|
+
imageBlank: 'images/lightbox-blank.gif', // (string) Path and the name of a blank image (one pixel)
|
35
|
+
// Configuration related to container image box
|
36
|
+
containerBorderSize: 10, // (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
|
37
|
+
containerResizeSpeed: 400, // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
|
38
|
+
// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
|
39
|
+
txtImage: 'Image', // (string) Specify text "Image"
|
40
|
+
txtOf: 'of', // (string) Specify text "of"
|
41
|
+
// Configuration related to keyboard navigation
|
42
|
+
keyToClose: 'c', // (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
|
43
|
+
keyToPrev: 'p', // (string) (p = previous) Letter to show the previous image
|
44
|
+
keyToNext: 'n', // (string) (n = next) Letter to show the next image.
|
45
|
+
// Don't alter these variables in any way
|
46
|
+
imageArray: [],
|
47
|
+
activeImage: 0
|
48
|
+
}, settings);
|
49
|
+
// Caching the jQuery object with all elements matched
|
50
|
+
var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
|
51
|
+
/**
|
52
|
+
* Initializing the plugin calling the start function
|
53
|
+
*
|
54
|
+
* @return boolean false
|
55
|
+
*/
|
56
|
+
function _initialize() {
|
57
|
+
_start(this, jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
|
58
|
+
return false; // Avoid the browser following the link
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Start the jQuery lightBox plugin
|
63
|
+
*
|
64
|
+
* @param object objClicked The object (link) whick the user have clicked
|
65
|
+
* @param object jQueryMatchedObj The jQuery object with all elements matched
|
66
|
+
*/
|
67
|
+
function _start(objClicked, jQueryMatchedObj) {
|
68
|
+
// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
|
69
|
+
$('embed, object, select').css({ 'visibility' : 'hidden' });
|
70
|
+
// Call the function to create the markup structure; style some elements; assign events in some elements.
|
71
|
+
_set_interface();
|
72
|
+
// Unset total images in imageArray
|
73
|
+
settings.imageArray.length = 0;
|
74
|
+
// Unset image active information
|
75
|
+
settings.activeImage = 0;
|
76
|
+
// We have an image set? Or just an image? Let's see it.
|
77
|
+
if (jQueryMatchedObj.length == 1) {
|
78
|
+
settings.imageArray.push(new Array(objClicked.getAttribute('href'), objClicked.getAttribute('title')));
|
79
|
+
} else {
|
80
|
+
// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
|
81
|
+
for (var i = 0; i < jQueryMatchedObj.length; i++) {
|
82
|
+
settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'), jQueryMatchedObj[i].getAttribute('title')));
|
83
|
+
}
|
84
|
+
}
|
85
|
+
while (settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href')) {
|
86
|
+
settings.activeImage++;
|
87
|
+
}
|
88
|
+
// Call the function that prepares image exibition
|
89
|
+
_set_image_to_view();
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Create the jQuery lightBox plugin interface
|
94
|
+
*
|
95
|
+
* The HTML markup will be like that:
|
96
|
+
<div id="jquery-overlay"></div>
|
97
|
+
<div id="jquery-lightbox">
|
98
|
+
<div id="lightbox-container-image-box">
|
99
|
+
<div id="lightbox-container-image">
|
100
|
+
<img src="../fotos/XX.jpg" id="lightbox-image">
|
101
|
+
<div id="lightbox-nav">
|
102
|
+
<a href="#" id="lightbox-nav-btnPrev"></a>
|
103
|
+
<a href="#" id="lightbox-nav-btnNext"></a>
|
104
|
+
</div>
|
105
|
+
<div id="lightbox-loading">
|
106
|
+
<a href="#" id="lightbox-loading-link">
|
107
|
+
<img src="../images/lightbox-ico-loading.gif">
|
108
|
+
</a>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div id="lightbox-container-image-data-box">
|
113
|
+
<div id="lightbox-container-image-data">
|
114
|
+
<div id="lightbox-image-details">
|
115
|
+
<span id="lightbox-image-details-caption"></span>
|
116
|
+
<span id="lightbox-image-details-currentNumber"></span>
|
117
|
+
</div>
|
118
|
+
<div id="lightbox-secNav">
|
119
|
+
<a href="#" id="lightbox-secNav-btnClose">
|
120
|
+
<img src="../images/lightbox-btn-close.gif">
|
121
|
+
</a>
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
*
|
127
|
+
*/
|
128
|
+
function _set_interface() {
|
129
|
+
// Apply the HTML markup into body tag
|
130
|
+
$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
|
131
|
+
// Get page sizes
|
132
|
+
var arrPageSizes = ___getPageSize();
|
133
|
+
// Style overlay and show it
|
134
|
+
$('#jquery-overlay').css({
|
135
|
+
backgroundColor: settings.overlayBgColor,
|
136
|
+
opacity: settings.overlayOpacity,
|
137
|
+
width: arrPageSizes[0],
|
138
|
+
height: arrPageSizes[1]
|
139
|
+
}).fadeIn();
|
140
|
+
// Get page scroll
|
141
|
+
var arrPageScroll = ___getPageScroll();
|
142
|
+
// Calculate top and left offset for the jquery-lightbox div object and show it
|
143
|
+
$('#jquery-lightbox').css({
|
144
|
+
top: arrPageScroll[1] + (arrPageSizes[3] / 10),
|
145
|
+
left: arrPageScroll[0]
|
146
|
+
}).show();
|
147
|
+
// Assigning click events in elements to close overlay
|
148
|
+
$('#jquery-overlay,#jquery-lightbox').click(function() {
|
149
|
+
_finish();
|
150
|
+
});
|
151
|
+
// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
|
152
|
+
$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
|
153
|
+
_finish();
|
154
|
+
return false;
|
155
|
+
});
|
156
|
+
// If window was resized, calculate the new overlay dimensions
|
157
|
+
$(window).resize(function() {
|
158
|
+
// Get page sizes
|
159
|
+
var arrPageSizes = ___getPageSize();
|
160
|
+
// Style overlay and show it
|
161
|
+
$('#jquery-overlay').css({
|
162
|
+
width: arrPageSizes[0],
|
163
|
+
height: arrPageSizes[1]
|
164
|
+
});
|
165
|
+
// Get page scroll
|
166
|
+
var arrPageScroll = ___getPageScroll();
|
167
|
+
// Calculate top and left offset for the jquery-lightbox div object and show it
|
168
|
+
$('#jquery-lightbox').css({
|
169
|
+
top: arrPageScroll[1] + (arrPageSizes[3] / 10),
|
170
|
+
left: arrPageScroll[0]
|
171
|
+
});
|
172
|
+
});
|
173
|
+
}
|
174
|
+
|
175
|
+
/**
|
176
|
+
* Prepares image exibition; doing a image's preloader to calculate it's size
|
177
|
+
*
|
178
|
+
*/
|
179
|
+
function _set_image_to_view() { // show the loading
|
180
|
+
// Show the loading
|
181
|
+
$('#lightbox-loading').show();
|
182
|
+
if (settings.fixedNavigation) {
|
183
|
+
$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
|
184
|
+
} else {
|
185
|
+
// Hide some elements
|
186
|
+
$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
|
187
|
+
}
|
188
|
+
// Image preload process
|
189
|
+
var objImagePreloader = new Image();
|
190
|
+
objImagePreloader.onload = function() {
|
191
|
+
$('#lightbox-image').attr('src', settings.imageArray[settings.activeImage][0]);
|
192
|
+
// Perfomance an effect in the image container resizing it
|
193
|
+
_resize_container_image_box(objImagePreloader.width, objImagePreloader.height);
|
194
|
+
// clear onLoad, IE behaves irratically with animated gifs otherwise
|
195
|
+
objImagePreloader.onload = function() {};
|
196
|
+
};
|
197
|
+
objImagePreloader.src = settings.imageArray[settings.activeImage][0];
|
198
|
+
}
|
199
|
+
|
200
|
+
;
|
201
|
+
/**
|
202
|
+
* Perfomance an effect in the image container resizing it
|
203
|
+
*
|
204
|
+
* @param integer intImageWidth The image's width that will be showed
|
205
|
+
* @param integer intImageHeight The image's height that will be showed
|
206
|
+
*/
|
207
|
+
function _resize_container_image_box(intImageWidth, intImageHeight) {
|
208
|
+
// Get current width and height
|
209
|
+
var intCurrentWidth = $('#lightbox-container-image-box').width();
|
210
|
+
var intCurrentHeight = $('#lightbox-container-image-box').height();
|
211
|
+
// Get the width and height of the selected image plus the padding
|
212
|
+
var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image's width and the left and right padding value
|
213
|
+
var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image's height and the left and right padding value
|
214
|
+
// Diferences
|
215
|
+
var intDiffW = intCurrentWidth - intWidth;
|
216
|
+
var intDiffH = intCurrentHeight - intHeight;
|
217
|
+
// Perfomance the effect
|
218
|
+
$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight }, settings.containerResizeSpeed, function() { _show_image(); });
|
219
|
+
if (( intDiffW == 0 ) && ( intDiffH == 0 )) {
|
220
|
+
if ($.browser.msie) {
|
221
|
+
___pause(250);
|
222
|
+
} else {
|
223
|
+
___pause(100);
|
224
|
+
}
|
225
|
+
}
|
226
|
+
$('#lightbox-container-image-data-box').css({ width: intImageWidth });
|
227
|
+
$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
|
228
|
+
}
|
229
|
+
|
230
|
+
;
|
231
|
+
/**
|
232
|
+
* Show the prepared image
|
233
|
+
*
|
234
|
+
*/
|
235
|
+
function _show_image() {
|
236
|
+
$('#lightbox-loading').hide();
|
237
|
+
$('#lightbox-image').fadeIn(function() {
|
238
|
+
_show_image_data();
|
239
|
+
_set_navigation();
|
240
|
+
});
|
241
|
+
_preload_neighbor_images();
|
242
|
+
}
|
243
|
+
|
244
|
+
;
|
245
|
+
/**
|
246
|
+
* Show the image information
|
247
|
+
*
|
248
|
+
*/
|
249
|
+
function _show_image_data() {
|
250
|
+
$('#lightbox-container-image-data-box').slideDown('fast');
|
251
|
+
$('#lightbox-image-details-caption').hide();
|
252
|
+
if (settings.imageArray[settings.activeImage][1]) {
|
253
|
+
$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
|
254
|
+
}
|
255
|
+
// If we have a image set, display 'Image X of X'
|
256
|
+
if (settings.imageArray.length > 1) {
|
257
|
+
$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Display the button navigations
|
263
|
+
*
|
264
|
+
*/
|
265
|
+
function _set_navigation() {
|
266
|
+
$('#lightbox-nav').show();
|
267
|
+
|
268
|
+
// Instead to define this configuration in CSS file, we define here. And it's need to IE. Just.
|
269
|
+
$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
|
270
|
+
|
271
|
+
// Show the prev button, if not the first image in set
|
272
|
+
if (settings.activeImage != 0) {
|
273
|
+
if (settings.fixedNavigation) {
|
274
|
+
$('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
|
275
|
+
.unbind()
|
276
|
+
.bind('click', function() {
|
277
|
+
settings.activeImage = settings.activeImage - 1;
|
278
|
+
_set_image_to_view();
|
279
|
+
return false;
|
280
|
+
});
|
281
|
+
} else {
|
282
|
+
// Show the images button for Next buttons
|
283
|
+
$('#lightbox-nav-btnPrev').unbind().hover(
|
284
|
+
function() {
|
285
|
+
$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
|
286
|
+
},
|
287
|
+
function() {
|
288
|
+
$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
|
289
|
+
}).show().bind('click', function() {
|
290
|
+
settings.activeImage = settings.activeImage - 1;
|
291
|
+
_set_image_to_view();
|
292
|
+
return false;
|
293
|
+
});
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
// Show the next button, if not the last image in set
|
298
|
+
if (settings.activeImage != ( settings.imageArray.length - 1 )) {
|
299
|
+
if (settings.fixedNavigation) {
|
300
|
+
$('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
|
301
|
+
.unbind()
|
302
|
+
.bind('click', function() {
|
303
|
+
settings.activeImage = settings.activeImage + 1;
|
304
|
+
_set_image_to_view();
|
305
|
+
return false;
|
306
|
+
});
|
307
|
+
} else {
|
308
|
+
// Show the images button for Next buttons
|
309
|
+
$('#lightbox-nav-btnNext').unbind().hover(
|
310
|
+
function() {
|
311
|
+
$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
|
312
|
+
},
|
313
|
+
function() {
|
314
|
+
$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
|
315
|
+
}).show().bind('click', function() {
|
316
|
+
settings.activeImage = settings.activeImage + 1;
|
317
|
+
_set_image_to_view();
|
318
|
+
return false;
|
319
|
+
});
|
320
|
+
}
|
321
|
+
}
|
322
|
+
// Enable keyboard navigation
|
323
|
+
_enable_keyboard_navigation();
|
324
|
+
}
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Enable a support to keyboard navigation
|
328
|
+
*
|
329
|
+
*/
|
330
|
+
function _enable_keyboard_navigation() {
|
331
|
+
$(document).keydown(function(objEvent) {
|
332
|
+
_keyboard_action(objEvent);
|
333
|
+
});
|
334
|
+
}
|
335
|
+
|
336
|
+
/**
|
337
|
+
* Disable the support to keyboard navigation
|
338
|
+
*
|
339
|
+
*/
|
340
|
+
function _disable_keyboard_navigation() {
|
341
|
+
$(document).unbind();
|
342
|
+
}
|
343
|
+
|
344
|
+
/**
|
345
|
+
* Perform the keyboard actions
|
346
|
+
*
|
347
|
+
*/
|
348
|
+
function _keyboard_action(objEvent) {
|
349
|
+
// To ie
|
350
|
+
if (objEvent == null) {
|
351
|
+
keycode = event.keyCode;
|
352
|
+
escapeKey = 27;
|
353
|
+
// To Mozilla
|
354
|
+
} else {
|
355
|
+
keycode = objEvent.keyCode;
|
356
|
+
escapeKey = objEvent.DOM_VK_ESCAPE;
|
357
|
+
}
|
358
|
+
// Get the key in lower case form
|
359
|
+
key = String.fromCharCode(keycode).toLowerCase();
|
360
|
+
// Verify the keys to close the ligthBox
|
361
|
+
if (( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey )) {
|
362
|
+
_finish();
|
363
|
+
}
|
364
|
+
// Verify the key to show the previous image
|
365
|
+
if (( key == settings.keyToPrev ) || ( keycode == 37 )) {
|
366
|
+
// If we're not showing the first image, call the previous
|
367
|
+
if (settings.activeImage != 0) {
|
368
|
+
settings.activeImage = settings.activeImage - 1;
|
369
|
+
_set_image_to_view();
|
370
|
+
_disable_keyboard_navigation();
|
371
|
+
}
|
372
|
+
}
|
373
|
+
// Verify the key to show the next image
|
374
|
+
if (( key == settings.keyToNext ) || ( keycode == 39 )) {
|
375
|
+
// If we're not showing the last image, call the next
|
376
|
+
if (settings.activeImage != ( settings.imageArray.length - 1 )) {
|
377
|
+
settings.activeImage = settings.activeImage + 1;
|
378
|
+
_set_image_to_view();
|
379
|
+
_disable_keyboard_navigation();
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Preload prev and next images being showed
|
386
|
+
*
|
387
|
+
*/
|
388
|
+
function _preload_neighbor_images() {
|
389
|
+
if ((settings.imageArray.length - 1) > settings.activeImage) {
|
390
|
+
objNext = new Image();
|
391
|
+
objNext.src = settings.imageArray[settings.activeImage + 1][0];
|
392
|
+
}
|
393
|
+
if (settings.activeImage > 0) {
|
394
|
+
objPrev = new Image();
|
395
|
+
objPrev.src = settings.imageArray[settings.activeImage - 1][0];
|
396
|
+
}
|
397
|
+
}
|
398
|
+
|
399
|
+
/**
|
400
|
+
* Remove jQuery lightBox plugin HTML markup
|
401
|
+
*
|
402
|
+
*/
|
403
|
+
function _finish() {
|
404
|
+
$('#jquery-lightbox').remove();
|
405
|
+
$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
|
406
|
+
// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
|
407
|
+
$('embed, object, select').css({ 'visibility' : 'visible' });
|
408
|
+
}
|
409
|
+
|
410
|
+
/**
|
411
|
+
/ THIRD FUNCTION
|
412
|
+
* getPageSize() by quirksmode.com
|
413
|
+
*
|
414
|
+
* @return Array Return an array with page width, height and window width, height
|
415
|
+
*/
|
416
|
+
function ___getPageSize() {
|
417
|
+
var xScroll, yScroll;
|
418
|
+
if (window.innerHeight && window.scrollMaxY) {
|
419
|
+
xScroll = window.innerWidth + window.scrollMaxX;
|
420
|
+
yScroll = window.innerHeight + window.scrollMaxY;
|
421
|
+
} else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
|
422
|
+
xScroll = document.body.scrollWidth;
|
423
|
+
yScroll = document.body.scrollHeight;
|
424
|
+
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
|
425
|
+
xScroll = document.body.offsetWidth;
|
426
|
+
yScroll = document.body.offsetHeight;
|
427
|
+
}
|
428
|
+
var windowWidth, windowHeight;
|
429
|
+
if (self.innerHeight) { // all except Explorer
|
430
|
+
if (document.documentElement.clientWidth) {
|
431
|
+
windowWidth = document.documentElement.clientWidth;
|
432
|
+
} else {
|
433
|
+
windowWidth = self.innerWidth;
|
434
|
+
}
|
435
|
+
windowHeight = self.innerHeight;
|
436
|
+
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
|
437
|
+
windowWidth = document.documentElement.clientWidth;
|
438
|
+
windowHeight = document.documentElement.clientHeight;
|
439
|
+
} else if (document.body) { // other Explorers
|
440
|
+
windowWidth = document.body.clientWidth;
|
441
|
+
windowHeight = document.body.clientHeight;
|
442
|
+
}
|
443
|
+
// for small pages with total height less then height of the viewport
|
444
|
+
if (yScroll < windowHeight) {
|
445
|
+
pageHeight = windowHeight;
|
446
|
+
} else {
|
447
|
+
pageHeight = yScroll;
|
448
|
+
}
|
449
|
+
// for small pages with total width less then width of the viewport
|
450
|
+
if (xScroll < windowWidth) {
|
451
|
+
pageWidth = xScroll;
|
452
|
+
} else {
|
453
|
+
pageWidth = windowWidth;
|
454
|
+
}
|
455
|
+
arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
|
456
|
+
return arrayPageSize;
|
457
|
+
}
|
458
|
+
|
459
|
+
;
|
460
|
+
/**
|
461
|
+
/ THIRD FUNCTION
|
462
|
+
* getPageScroll() by quirksmode.com
|
463
|
+
*
|
464
|
+
* @return Array Return an array with x,y page scroll values.
|
465
|
+
*/
|
466
|
+
function ___getPageScroll() {
|
467
|
+
var xScroll, yScroll;
|
468
|
+
if (self.pageYOffset) {
|
469
|
+
yScroll = self.pageYOffset;
|
470
|
+
xScroll = self.pageXOffset;
|
471
|
+
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
|
472
|
+
yScroll = document.documentElement.scrollTop;
|
473
|
+
xScroll = document.documentElement.scrollLeft;
|
474
|
+
} else if (document.body) {// all other Explorers
|
475
|
+
yScroll = document.body.scrollTop;
|
476
|
+
xScroll = document.body.scrollLeft;
|
477
|
+
}
|
478
|
+
arrayPageScroll = new Array(xScroll, yScroll);
|
479
|
+
return arrayPageScroll;
|
480
|
+
}
|
481
|
+
|
482
|
+
;
|
483
|
+
/**
|
484
|
+
* Stop the code execution from a escified time in milisecond
|
485
|
+
*
|
486
|
+
*/
|
487
|
+
function ___pause(ms) {
|
488
|
+
var date = new Date();
|
489
|
+
curDate = null;
|
490
|
+
do { var curDate = new Date(); }
|
491
|
+
while (curDate - date < ms);
|
492
|
+
}
|
493
|
+
|
494
|
+
;
|
495
|
+
// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
|
496
|
+
return this.unbind('click').click(_initialize);
|
497
|
+
};
|
498
|
+
})(jQuery); // Call and execute the function immediately passing the jQuery object
|
@@ -0,0 +1,35 @@
|
|
1
|
+
@import "vars";
|
2
|
+
@import "compass/css3/box";
|
3
|
+
@import "compass/css3/border-radius";
|
4
|
+
|
5
|
+
@mixin carousel {
|
6
|
+
@include border-radius(5px);
|
7
|
+
|
8
|
+
margin-top: 1em;
|
9
|
+
|
10
|
+
>li {
|
11
|
+
margin: 0.5em;
|
12
|
+
width: 140px;
|
13
|
+
}
|
14
|
+
|
15
|
+
figcaption {
|
16
|
+
text-align: center;
|
17
|
+
font-size: 10pt;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
ul.carousel-horizontal {
|
22
|
+
@include carousel;
|
23
|
+
@include display-box;
|
24
|
+
@include box-orient(horizontal);
|
25
|
+
|
26
|
+
overflow-x: auto;
|
27
|
+
}
|
28
|
+
|
29
|
+
ul.carousel-vertical {
|
30
|
+
@include carousel;
|
31
|
+
|
32
|
+
overflow-y: auto;
|
33
|
+
max-height: 400px;
|
34
|
+
width: 170px;
|
35
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery lightBox plugin
|
3
|
+
* This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
|
4
|
+
* and adapted to me for use like a plugin from jQuery.
|
5
|
+
* @name jquery-lightbox-0.5.css
|
6
|
+
* @author Leandro Vieira Pinho - http://leandrovieira.com
|
7
|
+
* @version 0.5
|
8
|
+
* @date April 11, 2008
|
9
|
+
* @category jQuery plugin
|
10
|
+
* @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
|
11
|
+
* @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
|
12
|
+
* @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
|
13
|
+
*/
|
14
|
+
#jquery-overlay {
|
15
|
+
position: absolute;
|
16
|
+
top: 0;
|
17
|
+
left: 0;
|
18
|
+
z-index: 90;
|
19
|
+
width: 100%;
|
20
|
+
height: 500px;
|
21
|
+
}
|
22
|
+
#jquery-lightbox {
|
23
|
+
position: absolute;
|
24
|
+
top: 0;
|
25
|
+
left: 0;
|
26
|
+
width: 100%;
|
27
|
+
z-index: 100;
|
28
|
+
text-align: center;
|
29
|
+
line-height: 0;
|
30
|
+
}
|
31
|
+
#jquery-lightbox a img { border: none; }
|
32
|
+
#lightbox-container-image-box {
|
33
|
+
position: relative;
|
34
|
+
background-color: #fff;
|
35
|
+
width: 250px;
|
36
|
+
height: 250px;
|
37
|
+
margin: 0 auto;
|
38
|
+
}
|
39
|
+
#lightbox-container-image { padding: 10px; }
|
40
|
+
#lightbox-loading {
|
41
|
+
position: absolute;
|
42
|
+
top: 40%;
|
43
|
+
left: 0%;
|
44
|
+
height: 25%;
|
45
|
+
width: 100%;
|
46
|
+
text-align: center;
|
47
|
+
line-height: 0;
|
48
|
+
}
|
49
|
+
#lightbox-nav {
|
50
|
+
position: absolute;
|
51
|
+
top: 0;
|
52
|
+
left: 0;
|
53
|
+
height: 100%;
|
54
|
+
width: 100%;
|
55
|
+
z-index: 10;
|
56
|
+
}
|
57
|
+
#lightbox-container-image-box > #lightbox-nav { left: 0; }
|
58
|
+
#lightbox-nav a { outline: none;}
|
59
|
+
#lightbox-nav-btnPrev, #lightbox-nav-btnNext {
|
60
|
+
width: 49%;
|
61
|
+
height: 100%;
|
62
|
+
zoom: 1;
|
63
|
+
display: block;
|
64
|
+
}
|
65
|
+
#lightbox-nav-btnPrev {
|
66
|
+
left: 0;
|
67
|
+
float: left;
|
68
|
+
}
|
69
|
+
#lightbox-nav-btnNext {
|
70
|
+
right: 0;
|
71
|
+
float: right;
|
72
|
+
}
|
73
|
+
#lightbox-container-image-data-box {
|
74
|
+
font: 10px Verdana, Helvetica, sans-serif;
|
75
|
+
background-color: #fff;
|
76
|
+
margin: 0 auto;
|
77
|
+
line-height: 1.4em;
|
78
|
+
overflow: auto;
|
79
|
+
width: 100%;
|
80
|
+
padding: 0 10px 0;
|
81
|
+
}
|
82
|
+
#lightbox-container-image-data {
|
83
|
+
padding: 0 10px;
|
84
|
+
color: #666;
|
85
|
+
}
|
86
|
+
#lightbox-container-image-data #lightbox-image-details {
|
87
|
+
width: 70%;
|
88
|
+
float: left;
|
89
|
+
text-align: left;
|
90
|
+
}
|
91
|
+
#lightbox-image-details-caption { font-weight: bold; }
|
92
|
+
#lightbox-image-details-currentNumber {
|
93
|
+
display: block;
|
94
|
+
clear: left;
|
95
|
+
padding-bottom: 1.0em;
|
96
|
+
}
|
97
|
+
#lightbox-secNav-btnClose {
|
98
|
+
width: 66px;
|
99
|
+
float: right;
|
100
|
+
padding-bottom: 0.7em;
|
101
|
+
}
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carousel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tim Morgan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: compass
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jquery-rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: bundler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: jeweler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: paperclip
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Adds CoffeeScript and SCSS files to your Rails apps allowing you to easily
|
127
|
+
create an Ajax-powered Carousel.
|
128
|
+
email: rubygems@timothymorgan.info
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files:
|
132
|
+
- LICENSE.txt
|
133
|
+
- README.md
|
134
|
+
files:
|
135
|
+
- LICENSE.txt
|
136
|
+
- README.md
|
137
|
+
- carousel.gemspec
|
138
|
+
- lib/carousel.rb
|
139
|
+
- lib/carousel/paperclip/round_corners.rb
|
140
|
+
- vendor/assets/images/lightbox/blank.gif
|
141
|
+
- vendor/assets/images/lightbox/close.gif
|
142
|
+
- vendor/assets/images/lightbox/loading.gif
|
143
|
+
- vendor/assets/images/lightbox/next.gif
|
144
|
+
- vendor/assets/images/lightbox/prev.gif
|
145
|
+
- vendor/assets/javascripts/carousel.js.coffee.erb
|
146
|
+
- vendor/assets/javascripts/jquery.lightbox-0.5.js
|
147
|
+
- vendor/assets/stylesheets/carousel.css.scss
|
148
|
+
- vendor/assets/stylesheets/jquery.lightbox-0.5.css
|
149
|
+
homepage: http://github.com/RISCfuture/carousel
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
segments:
|
163
|
+
- 0
|
164
|
+
hash: 2934254892831708062
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 1.8.23
|
174
|
+
signing_key:
|
175
|
+
specification_version: 3
|
176
|
+
summary: Simple image carousels in your Rails apps.
|
177
|
+
test_files: []
|