Coder Social home page Coder Social logo

morganestes / h5-lightbox Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 5.0 483 KB

A jQuery lightbox built on the HTML5 data attribute

Home Page: http://www.morganestes.me/h5-lightbox

License: MIT License

CSS 11.68% JavaScript 42.55% HTML 31.73% Less 14.04%

h5-lightbox's Introduction

Hi there ๐Ÿ‘‹

I'm mainly a web developer (PHP, JS, CSS, and WordPress are my bread and butter), but love to try new languages and ideas to create solutions for problems I encounter. I've dabbled in Python, Ruby, Perl, shell scripting, C++, C#, VB.NET, and a few others, but PHP is my go-to language.

When I'm not writing code, I spend time with my family or on my ham radio (W3PHP is my call sign cuz I'm nerdy like that).

  • ๐Ÿ”ญ Iโ€™m currently working on multiple WordPress products for LOCALiQ.
  • ๐ŸŒฑ Iโ€™m currently learning React.
  • ๐Ÿ’ฌ Ask me about WordPress and I'll try to help.
  • ๐Ÿ“ซ How to reach me: morganestes.com
  • ๐Ÿ˜„ Pronouns: he/him

h5-lightbox's People

Contributors

bitdeli-chef avatar morganestes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

h5-lightbox's Issues

Missing alt text on imgLarge

To make the lightbox more Pinterest friendly I suggest the following modification:

     return this.each(function()
    {

        var $this = $(this),
            imgLarge = $this.attr(opt.target),
            altText = $this.attr("alt"),
            /**
             * check if the image has the proper data attribute
             * @param {String} img_large Attribute set in options.
             * @returns {Boolean}
             */
            isLightbox = function(imgLarge)
            {
                return (typeof imgLarge !== "undefined");
            };

        if (isLightbox(imgLarge))
        {
            $this.wrap("<a class='" + opt.wrapperClass + "' href='" + imgLarge + "'" + "' alt='" + altText + "'></a>");
        }

        // lightbox implementation
        $("a." + opt.wrapperClass).click(function(e)
        {
            e.preventDefault();
            var lightbox,
                lbImageHref = $(this).attr("href"),
                lbImageAlt = $(this).attr("alt");

            if ($("#lightbox").length)
            {
                $("#lightbox-img").html("<img src='" + lbImageHref + "'' alt='" + lbImageAlt + "' />");
                $("#lightbox").show();
            }
            else
            {
                lightbox =
                    "<div id='lightbox'>" +
                    "<p>Click to close</p>" +
                    "<div id='lightbox-img'>" +
                    "<img src='" + lbImageHref + "'' alt='" + lbImageAlt + "' />" +
                    "</div>" +
                    "</div>";

                $("body").append(lightbox);
            }
        });

        $(document).on("click", "#lightbox", function()
        {
            $(this).hide();
        });

Issue about enlarging images

Hi.
I 've got 3 images on a page.
When I want that each image can be enlarge when i click on it, i have to refresh the page before each enlargement else it's only the first one a click which enlarge.

thank you to help me

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.