Code Monkey home page Code Monkey logo

lightbox2-rails's Introduction

๐ŸŒ  lightbox2-rails

Gem Version Gem Downloads

Lightbox2 for Rails asset pipeline

Installation

  1. Add to your Gemfile and install with bundler:
gem 'lightbox2-rails'
bundle install
  1. Add to your config/initializers/assets.rb in order to have the images for lightbox precompiled:
Rails.application.config.assets.precompile += %w( lightbox/* )
  1. Require the modified Lightbox2 javascript file in app/assets/javascripts/application.js:
//= require lightbox

Or in app/assets/javascripts/application.js.coffee:

#= require lightbox
  1. Require the modified Lightbox2 css file in app/assets/stylesheets/application.css:
*= require lightbox

Or in app/assets/javascripts/application.css.scss / app/assets/javascripts/application.css.sass:

@import 'lightbox';
@import lightbox
  1. Changing default options (Optional)

Please refer to Lightbox2 project page.

Acknowledgements

Lightbox2 created by Lokesh Dhakar, licensed under the Creative Commons Attribution 2.5 License

Copyright Gavin Lam, released under the MIT License.

lightbox2-rails's People

Contributors

gavinkflam avatar jakethesnake3p0 avatar johansmitsnl avatar nasa42 avatar neutrino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lightbox2-rails's Issues

Pass over the owner ship of the gem

We had a conversation by email that you no longer have a active project with lightbox.
I'm more then happy to take over the ownership of the gem.
Please add me as the new oner on rubygems.

Lightbox fails to attach event handler to elements and also fails to work at all

The JS file is included in the head and apparently that results in the event 'click' handler not being applied to the element. When I put //= require lightbox in its own JS file and included it near the bottom of the <body> tag the event handler was successfully attached.

However it still didn't help anything as the link still navigates directly to the image and doesn't stay on the page and load the lightbox.

My link has data-lightbox="weddings" attribute. Also for what its worth, the JS console reads (in Google Chrome): Resource interpreted as Document but transferred with MIME type image/jpeg: "[image URL]".

I'm using jQuery v2.2.1 (using jquery-rails and //= require jquery2 inside of application.js)

Lightbox overlay duplicates when using turbolinks

How to reproduce:

  1. Load page
  2. Follow some (internal) link (this time, page is loaded using turbolinks). It's working nice at this point.
  3. Follow another (internal) link
  4. Now there's another div#lightboxOverlay and div#lightbox at the bottom of body and the browser is showing the spinner inside the empty overlay.

Javascript is included at the bottom of body:

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

A workaround that worked for me was adding div#lightbox-container at the top of the body and modify lightbox.js in Lightbox.prototype.build function:

$('#lightbox-container').html('');
$("<div id='lightboxOverlay' class='lightboxOverlay'></div><div id='lightbox' class='lightbox'><div class='lb-outerContainer'><div class='lb-container'><img class='lb-image' src='' /><div class='lb-nav'><a class='lb-prev' href='' ></a><a class='lb-next' href='' ></a></div><div class='lb-loader'><a class='lb-cancel'></a></div></div></div><div class='lb-dataContainer'><div class='lb-data'><div class='lb-details'><span class='lb-caption'></span><span class='lb-number'></span></div><div class='lb-closeContainer'><a class='lb-close'></a></div></div></div></div>").appendTo($('#lightbox-container'));

I was unable to find anything better :-(

SVG image not open in lightbox

i m trying to open a svg image in lightbox but its not showing .....

  <a class="thumbnail" href="<%= inline_svg_tag pic.image.url(:medium)%>", data-lightbox="pic" data-title=" 
    <%=pic.description%>">
    <%= inline_svg_tag  "check.svg", class: 'some-class' %>
  </a>

Lightbox not loading fingerprinted images

I just installed Lightbox2 rails, and I can see the below fingerprinted images in my public/assets folder, but these images fail to load.

Is anyone else seeing this issue? I am on lightbox2-rails (2.8.2.1) and Rails 4.0.13.

http://localhost:3000/assets/lightbox/loading.gif Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:3000/assets/lightbox/close.png Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:3000/assets/lightbox/next.png Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:3000/assets/lightbox/prev.png Failed to load resource: the server responded with a status of 404 (Not Found)

NoMethodError: undefined method `protocol' for nil:NilClass

No errors in development mode, but when I deploy via Capistrano I get this error during asset precompile:

NoMethodError: undefined method `protocol' for nil:NilClass
  (in /home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/lightbox2-rails-2.7.1/vendor/assets/stylesheets/lightbox.css.erb)
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers/asset_url_helper.rb:227:in `compute_asset_host'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers/asset_url_helper.rb:143:in `asset_path'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:91:in `asset_path'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers/asset_url_helper.rb:162:in `asset_url'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers/asset_url_helper.rb:299:in `image_url'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/lightbox2-rails-2.7.1/vendor/assets/stylesheets/lightbox.css.erb:4:in `block in singleton class'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/lightbox2-rails-2.7.1/vendor/assets/stylesheets/lightbox.css.erb:-5:in `instance_eval'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/lightbox2-rails-2.7.1/vendor/assets/stylesheets/lightbox.css.erb:-5:in `singleton class'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/lightbox2-rails-2.7.1/vendor/assets/stylesheets/lightbox.css.erb:-7:in `__tilt_4856280'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/context.rb:197:in `block in evaluate'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/context.rb:194:in `each'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/context.rb:194:in `evaluate'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:12:in `initialize'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:374:in `new'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:374:in `block in build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:395:in `circular_call_protection'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:373:in `build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:94:in `block in build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/caching.rb:58:in `cache_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:93:in `build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:287:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:61:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:105:in `each'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/processed_asset.rb:16:in `initialize'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:374:in `new'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:374:in `block in build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:395:in `circular_call_protection'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:373:in `build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:94:in `block in build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/caching.rb:58:in `cache_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:93:in `build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:287:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:61:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/bundled_asset.rb:37:in `init_with'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/asset.rb:24:in `from_hash'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/caching.rb:54:in `cache_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:93:in `build_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:287:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:61:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/manifest.rb:211:in `block in find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/manifest.rb:257:in `benchmark'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/manifest.rb:210:in `find_asset'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/manifest.rb:119:in `block in compile'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/manifest.rb:118:in `each'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/manifest.rb:118:in `compile'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/rake/sprocketstask.rb:146:in `with_logger'
/home/user_account/rails_deployments/www/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile

Bundler could not find compatible versions for gem "rails":

I tried including gem 'lightbox-rails' and ran bundle install

Resolving dependencies...
Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    lightbox-rails (>= 0) ruby depends on
      rails (~> 3.2.8) ruby

    rails (4.2.4)

I'm running ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.