npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-bootstrap-lightbox-txl-fork

v0.12.0

Published

An AngularJS lightbox built using UI Bootstrap Modal.

Downloads

6

Readme

angular-bootstrap-lightbox

This lightbox displays images using an AngularUI Bootstrap Modal (v0.14).

When the lightbox is opened, navigating to the previous/next image can be achieved by clicking buttons above the image, clicking the left/right arrow keys, or swiping to the left/right (optional with ngTouch). The escape key for closing the modal is automatically binded by AngularUI Bootstrap.

Large images are scaled to fit inside the window. An optional image caption overlays the top left corner of the image.

Demos

Demos / Plunker

Setup

  1. Install in one of the following ways:
  • Install with Bower: bower install angular-bootstrap-lightbox --save
  • Install with npm: npm install angular-bootstrap-lightbox --save
  • Manually save the script and stylesheet from dist.
  1. Include the stylesheet in your app:
<link rel="stylesheet" href="angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.css">
  1. Include the script in your app:
<script src="angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.js"></script>
  1. The Angular module is named bootstrapLightbox. Add it as a dependency to your module:
angular.module('app', ['bootstrapLightbox']);
  1. Optional dependencies:

Basic example

Gallery:

<ul ng-controller="GalleryCtrl">
  <li ng-repeat="image in images">
    <a ng-click="openLightboxModal($index)">
      <img ng-src="{{image.thumbUrl}}" class="img-thumbnail">
    </a>
  </li>
</ul>

Controller:

angular.module('app').controller('GalleryCtrl', function ($scope, Lightbox) {
  $scope.images = [
    {
      'url': '1.jpg',
      'caption': 'Optional caption',
      'thumbUrl': 'thumb1.jpg' // used only for this example
    },
    {
      'url': '2.gif',
      'thumbUrl': 'thumb2.jpg'
    },
    {
      'url': '3.png',
      'thumbUrl': 'thumb3.png'
    }
  ];

  $scope.openLightboxModal = function (index) {
    Lightbox.openModal($scope.images, index);
  };
});

Configuration

Changing the appearance of the modal lightbox

The default view template for the lightbox is lightbox.html. Its look can be changed by making your own custom template and/or adding CSS rules; for example, use the selector .lightbox-image-caption to style the caption.

If you make your own template and save it at lightbox.html, no further code is necessary. If you save it at a different path, set it in the provider:

angular.module('app').config(function (LightboxProvider) {
  // set a custom template
  LightboxProvider.templateUrl = 'path/to/your-template.html';
});

Disabling the keyboard navigation

The keyboard navigation in the lightbox with the left/right arrow keys can be enabled/disabled at any time by changing the value of the boolean Lightbox.keyboardNavEnabled.

Array of images

The first argument to Lightbox.openModal must be an array, and its elements may be of any type. In the basic example above, it is an array of objects with properties url and caption, but this is only the default and is not required. To let the Lightbox service know the correct values, set these methods in the provider:

angular.module('app').config(function (LightboxProvider) {
  LightboxProvider.getImageUrl = function (image) {
    return '/base/dir/' + image.getName();
  };

  LightboxProvider.getImageCaption = function (image) {
    return image.label;
  };
});

Image and modal scaling

By default, images are scaled only if they are too large for the modal to contain without scrolling.

If you want all images to be scaled to the maximum possible dimensions, update the Lightbox.fullScreenMode boolean:

angular.module('app').config(function (LightboxProvider) {
  LightboxProvider.fullScreenMode = true;
});

For more custom behaviour, see the documentation of the methods calculateImageDimensionLimits and calculateModalDimensions.

Videos

An element in the array of 'images' is considered a video if it is an object with a type property having the value video (see the demo). To change this, write your own LightboxProvider.isVideo method.

By default, a video is embedded directly if its url ends in .mp4, .ogg, or .webm. Every other url is considered a video from an external sharing service (such as YouTube). To change this check, edit the LightboxProvider.isSharedVideo method. The ng-videosharing-embed library is used for embedding shared videos if it is included in your app. You can use another video library by changing the template.

For now, the maximum video dimensions are fixed at 1280x720 (16:9).

Development

  • API documentation of the services and directive in the Angular module

  • Setup:

    npm install
    bower install
  • Build:

    grunt
  • Generate docs:

    grunt jsdoc2md
  • Serve the GitHub Pages:

    git checkout gh-pages
    git checkout master -- dist/angular-bootstrap-lightbox.min.js dist/angular-bootstrap-lightbox.min.css
    bundle install
    bundle exec jekyll serve