angular-bootstrap-lightbox
Advanced tools
Comparing version 0.8.0 to 0.9.0
14
api.md
@@ -16,2 +16,3 @@ <a name="bootstrapLightbox"></a> | ||
* [.isVideo](#bootstrapLightbox.Lightbox.isVideo) ⇒ <code>Boolean</code> | ||
* [.isSharedVideo](#bootstrapLightbox.Lightbox.isSharedVideo) ⇒ <code>Boolean</code> | ||
* [.images](#bootstrapLightbox.Lightbox.images) : <code>Array</code> | ||
@@ -66,2 +67,3 @@ * [.index](#bootstrapLightbox.Lightbox.index) : <code>Number</code> | ||
* [.isVideo](#bootstrapLightbox.Lightbox.isVideo) ⇒ <code>Boolean</code> | ||
* [.isSharedVideo](#bootstrapLightbox.Lightbox.isSharedVideo) ⇒ <code>Boolean</code> | ||
* [.images](#bootstrapLightbox.Lightbox.images) : <code>Array</code> | ||
@@ -148,2 +150,13 @@ * [.index](#bootstrapLightbox.Lightbox.index) : <code>Number</code> | ||
<a name="bootstrapLightbox.Lightbox.isSharedVideo"></a> | ||
#### Lightbox.isSharedVideo ⇒ <code>Boolean</code> | ||
**Kind**: static property of <code>[Lightbox](#bootstrapLightbox.Lightbox)</code> | ||
**Returns**: <code>Boolean</code> - Whether the provided element is a video that is to be | ||
embedded with an external service like YouTube. By default, this is | ||
determined by the url not ending in `.mp4`, `.ogg`, or `.webm`. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| image | <code>\*</code> | An element in the array of images. | | ||
<a name="bootstrapLightbox.Lightbox.images"></a> | ||
@@ -206,2 +219,3 @@ #### Lightbox.images : <code>Array</code> | ||
| newIndex | <code>Number</code> | The index in `newImages` to set as the current image. | | ||
| modalParams | <code>Object</code> | Custom params for the angular UI bootstrap modal (in $modal.open()). | | ||
@@ -208,0 +222,0 @@ <a name="bootstrapLightbox.Lightbox.closeModal"></a> |
{ | ||
"name": "angular-bootstrap-lightbox", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"main": [ | ||
@@ -15,13 +15,13 @@ "dist/angular-bootstrap-lightbox.js", | ||
"dependencies": { | ||
"angular": "^1.4.4", | ||
"angular-bootstrap": "^0.13.3" | ||
"angular": "^1.4.5", | ||
"angular-bootstrap": "^0.13.4" | ||
}, | ||
"devDependencies": { | ||
"angular-loading-bar": "^0.8.0", | ||
"angular-touch": "^1.4.4", | ||
"angular-touch": "^1.4.5", | ||
"ng-videosharing-embed": "^0.3.3" | ||
}, | ||
"resolutions": { | ||
"angular": "^1.4.4" | ||
"angular": "^1.4.5" | ||
} | ||
} |
@@ -319,2 +319,4 @@ /** | ||
* current image. | ||
* @param {Object} modalParams Custom params for the angular UI | ||
* bootstrap modal (in $modal.open()). | ||
* @return {Object} The created UI Bootstrap modal instance. | ||
@@ -325,3 +327,3 @@ * @type {Function} | ||
*/ | ||
Lightbox.openModal = function (newImages, newIndex) { | ||
Lightbox.openModal = function (newImages, newIndex, modalParams) { | ||
Lightbox.images = newImages; | ||
@@ -331,3 +333,3 @@ Lightbox.setImage(newIndex); | ||
// store the modal instance so we can close it manually if we need to | ||
Lightbox.modalInstance = $modal.open({ | ||
Lightbox.modalInstance = $modal.open(angular.extend({ | ||
'templateUrl': Lightbox.templateUrl, | ||
@@ -341,3 +343,3 @@ 'controller': ['$scope', function ($scope) { | ||
'windowClass': 'lightbox-modal' | ||
}); | ||
}, modalParams || {})); | ||
@@ -344,0 +346,0 @@ // modal close handler |
/*! angular-bootstrap-lightbox */ | ||
angular.module("bootstrapLightbox",["ui.bootstrap"]);try{angular.module("angular-loading-bar"),angular.module("bootstrapLightbox").requires.push("angular-loading-bar")}catch(e){}try{angular.module("ngTouch"),angular.module("bootstrapLightbox").requires.push("ngTouch")}catch(e){}try{angular.module("videosharing-embed"),angular.module("bootstrapLightbox").requires.push("videosharing-embed")}catch(e){}angular.module("bootstrapLightbox").run(["$templateCache",function(a){"use strict";a.put("lightbox.html",'<div class=modal-body ng-swipe-left=Lightbox.nextImage() ng-swipe-right=Lightbox.prevImage()><div class=lightbox-nav><button class=close aria-hidden=true ng-click=$dismiss()>×</button><div class=btn-group><a class="btn btn-xs btn-default" ng-click=Lightbox.prevImage()>‹ Previous</a> <a ng-href={{Lightbox.imageUrl}} target=_blank class="btn btn-xs btn-default" title="Open in new tab">Open image in new tab</a> <a class="btn btn-xs btn-default" ng-click=Lightbox.nextImage()>Next ›</a></div></div><div class=lightbox-image-container><div class=lightbox-image-caption><span>{{Lightbox.imageCaption}}</span></div><img ng-if=!Lightbox.isVideo(Lightbox.image) lightbox-src={{Lightbox.imageUrl}}> <div ng-if=Lightbox.isVideo(Lightbox.image) class="embed-responsive embed-responsive-16by9"><video ng-if=!Lightbox.isSharedVideo(Lightbox.image) lightbox-src={{Lightbox.imageUrl}} controls autoplay></video><embed-video ng-if=Lightbox.isSharedVideo(Lightbox.image) lightbox-src={{Lightbox.imageUrl}} ng-href={{Lightbox.imageUrl}} iframe-id=lightbox-video class=embed-responsive-item><a ng-href={{Lightbox.imageUrl}}>Watch video</a></embed-video></div></div></div>')}]),angular.module("bootstrapLightbox").service("ImageLoader",["$q",function(a){this.load=function(b){var c=a.defer(),d=new Image;return d.onload=function(){("boolean"==typeof this.complete&&this.complete===!1||"number"==typeof this.naturalWidth&&0===this.naturalWidth)&&c.reject(),c.resolve(d)},d.onerror=function(){c.reject()},d.src=b,c.promise}}]),angular.module("bootstrapLightbox").provider("Lightbox",function(){this.templateUrl="lightbox.html",this.fullScreenMode=!1,this.getImageUrl=function(a){return"string"==typeof a?a:a.url},this.getImageCaption=function(a){return a.caption},this.calculateImageDimensionLimits=function(a){return a.windowWidth>=768?{maxWidth:a.windowWidth-92,maxHeight:a.windowHeight-126}:{maxWidth:a.windowWidth-52,maxHeight:a.windowHeight-86}},this.calculateModalDimensions=function(a){var b=Math.max(400,a.imageDisplayWidth+32),c=Math.max(200,a.imageDisplayHeight+66);return(b>=a.windowWidth-20||a.windowWidth<768)&&(b="auto"),c>=a.windowHeight&&(c="auto"),{width:b,height:c}},this.isVideo=function(a){return"object"==typeof a&&a&&a.type?"video"===a.type:!1},this.isSharedVideo=function(a){return this.isVideo(a)&&!this.getImageUrl(a).match(/\.(mp4|ogg|webm)$/)},this.$get=["$document","$injector","$modal","$timeout","ImageLoader",function(a,b,c,d,e){var f=b.has("cfpLoadingBar")?b.get("cfpLoadingBar"):null,g={};return g.images=[],g.index=-1,g.templateUrl=this.templateUrl,g.fullScreenMode=this.fullScreenMode,g.getImageUrl=this.getImageUrl,g.getImageCaption=this.getImageCaption,g.calculateImageDimensionLimits=this.calculateImageDimensionLimits,g.calculateModalDimensions=this.calculateModalDimensions,g.isVideo=this.isVideo,g.isSharedVideo=this.isSharedVideo,g.keyboardNavEnabled=!1,g.image={},g.modalInstance=null,g.loading=!1,g.openModal=function(a,b){return g.images=a,g.setImage(b),g.modalInstance=c.open({templateUrl:g.templateUrl,controller:["$scope",function(a){a.Lightbox=g,g.keyboardNavEnabled=!0}],windowClass:"lightbox-modal"}),g.modalInstance.result["finally"](function(){g.images=[],g.index=1,g.image={},g.imageUrl=null,g.imageCaption=null,g.keyboardNavEnabled=!1,f&&f.complete()}),g.modalInstance},g.closeModal=function(a){return g.modalInstance.close(a)},g.setImage=function(a){if(!(a in g.images))throw"Invalid image.";g.loading=!0,f&&f.start();var b=g.images[a],c=g.getImageUrl(b),d=function(d){d=d||{},g.index=d.index||a,g.image=d.image||b,g.imageUrl=d.imageUrl||c,g.imageCaption=d.imageCaption||g.getImageCaption(b),g.loading=!1,f&&f.complete()};g.isVideo(b)?d():e.load(c).then(function(){d()},function(){d({imageUrl:"//:0",imageCaption:"Failed to load image"})})},g.firstImage=function(){g.setImage(0)},g.prevImage=function(){g.setImage((g.index-1+g.images.length)%g.images.length)},g.nextImage=function(){g.setImage((g.index+1)%g.images.length)},g.lastImage=function(){g.setImage(g.images.length-1)},g.setImages=function(a){g.images=a,g.setImage(g.index)},a.bind("keydown",function(a){if(g.keyboardNavEnabled){var b=null;switch(a.which){case 39:b="nextImage";break;case 37:b="prevImage"}null!==b&&-1===["input","textarea"].indexOf(a.target.tagName.toLowerCase())&&(d(function(){g[b]()}),a.preventDefault())}}),g}]}),angular.module("bootstrapLightbox").directive("lightboxSrc",["$window","ImageLoader","Lightbox",function(a,b,c){var d=function(a,b){var c=a.width,d=a.height,e=a.minWidth,f=a.minHeight,g=a.maxWidth,h=a.maxHeight,i=c,j=d;if(b){var k=Math.min(g/c,h/d),l=Math.round(c*k),m=Math.round(d*k);i=Math.max(e,l),j=Math.max(f,m)}else e>c&&f>d?c/d>g/h?(j=f,i=Math.round(c*f/d)):(i=e,j=Math.round(d*e/c)):e>c?(i=e,j=Math.round(d*e/c)):f>d&&(j=f,i=Math.round(c*f/d)),c>g&&d>h?c/d>g/h?(i=g,j=Math.round(d*g/c)):(j=h,i=Math.round(c*h/d)):c>g?(i=g,j=Math.round(d*g/c)):d>h&&(j=h,i=Math.round(c*h/d));return{width:i||0,height:j||0}},e=0,f=0;return{link:function(g,h,i){var j=function(){var b=a.innerWidth,g=a.innerHeight,i=c.calculateImageDimensionLimits({windowWidth:b,windowHeight:g,imageWidth:e,imageHeight:f}),j=d(angular.extend({width:e,height:f,minWidth:1,minHeight:1,maxWidth:3e3,maxHeight:3e3},i),c.fullScreenMode),k=c.calculateModalDimensions({windowWidth:b,windowHeight:g,imageDisplayWidth:j.width,imageDisplayHeight:j.height});h.css({width:j.width+"px",height:j.height+"px"}),angular.element(document.querySelector(".lightbox-modal .modal-dialog")).css({width:k.width+"px"}),angular.element(document.querySelector(".lightbox-modal .modal-content")).css({height:k.height+"px"})};g.$watch(function(){return i.lightboxSrc},function(a){c.isVideo(c.image)?(e=1280,f=720,j(),h[0].src=a):(h[0].src="//:0",b.load(a).then(function(b){e=b.naturalWidth,f=b.naturalHeight,j(),h[0].src=a},function(){e=0,f=0,j()}))}),angular.element(a).on("resize",j)}}}]); | ||
angular.module("bootstrapLightbox",["ui.bootstrap"]);try{angular.module("angular-loading-bar"),angular.module("bootstrapLightbox").requires.push("angular-loading-bar")}catch(e){}try{angular.module("ngTouch"),angular.module("bootstrapLightbox").requires.push("ngTouch")}catch(e){}try{angular.module("videosharing-embed"),angular.module("bootstrapLightbox").requires.push("videosharing-embed")}catch(e){}angular.module("bootstrapLightbox").run(["$templateCache",function(a){"use strict";a.put("lightbox.html",'<div class=modal-body ng-swipe-left=Lightbox.nextImage() ng-swipe-right=Lightbox.prevImage()><div class=lightbox-nav><button class=close aria-hidden=true ng-click=$dismiss()>×</button><div class=btn-group><a class="btn btn-xs btn-default" ng-click=Lightbox.prevImage()>‹ Previous</a> <a ng-href={{Lightbox.imageUrl}} target=_blank class="btn btn-xs btn-default" title="Open in new tab">Open image in new tab</a> <a class="btn btn-xs btn-default" ng-click=Lightbox.nextImage()>Next ›</a></div></div><div class=lightbox-image-container><div class=lightbox-image-caption><span>{{Lightbox.imageCaption}}</span></div><img ng-if=!Lightbox.isVideo(Lightbox.image) lightbox-src={{Lightbox.imageUrl}}> <div ng-if=Lightbox.isVideo(Lightbox.image) class="embed-responsive embed-responsive-16by9"><video ng-if=!Lightbox.isSharedVideo(Lightbox.image) lightbox-src={{Lightbox.imageUrl}} controls autoplay></video><embed-video ng-if=Lightbox.isSharedVideo(Lightbox.image) lightbox-src={{Lightbox.imageUrl}} ng-href={{Lightbox.imageUrl}} iframe-id=lightbox-video class=embed-responsive-item><a ng-href={{Lightbox.imageUrl}}>Watch video</a></embed-video></div></div></div>')}]),angular.module("bootstrapLightbox").service("ImageLoader",["$q",function(a){this.load=function(b){var c=a.defer(),d=new Image;return d.onload=function(){("boolean"==typeof this.complete&&this.complete===!1||"number"==typeof this.naturalWidth&&0===this.naturalWidth)&&c.reject(),c.resolve(d)},d.onerror=function(){c.reject()},d.src=b,c.promise}}]),angular.module("bootstrapLightbox").provider("Lightbox",function(){this.templateUrl="lightbox.html",this.fullScreenMode=!1,this.getImageUrl=function(a){return"string"==typeof a?a:a.url},this.getImageCaption=function(a){return a.caption},this.calculateImageDimensionLimits=function(a){return a.windowWidth>=768?{maxWidth:a.windowWidth-92,maxHeight:a.windowHeight-126}:{maxWidth:a.windowWidth-52,maxHeight:a.windowHeight-86}},this.calculateModalDimensions=function(a){var b=Math.max(400,a.imageDisplayWidth+32),c=Math.max(200,a.imageDisplayHeight+66);return(b>=a.windowWidth-20||a.windowWidth<768)&&(b="auto"),c>=a.windowHeight&&(c="auto"),{width:b,height:c}},this.isVideo=function(a){return"object"==typeof a&&a&&a.type?"video"===a.type:!1},this.isSharedVideo=function(a){return this.isVideo(a)&&!this.getImageUrl(a).match(/\.(mp4|ogg|webm)$/)},this.$get=["$document","$injector","$modal","$timeout","ImageLoader",function(a,b,c,d,e){var f=b.has("cfpLoadingBar")?b.get("cfpLoadingBar"):null,g={};return g.images=[],g.index=-1,g.templateUrl=this.templateUrl,g.fullScreenMode=this.fullScreenMode,g.getImageUrl=this.getImageUrl,g.getImageCaption=this.getImageCaption,g.calculateImageDimensionLimits=this.calculateImageDimensionLimits,g.calculateModalDimensions=this.calculateModalDimensions,g.isVideo=this.isVideo,g.isSharedVideo=this.isSharedVideo,g.keyboardNavEnabled=!1,g.image={},g.modalInstance=null,g.loading=!1,g.openModal=function(a,b,d){return g.images=a,g.setImage(b),g.modalInstance=c.open(angular.extend({templateUrl:g.templateUrl,controller:["$scope",function(a){a.Lightbox=g,g.keyboardNavEnabled=!0}],windowClass:"lightbox-modal"},d||{})),g.modalInstance.result["finally"](function(){g.images=[],g.index=1,g.image={},g.imageUrl=null,g.imageCaption=null,g.keyboardNavEnabled=!1,f&&f.complete()}),g.modalInstance},g.closeModal=function(a){return g.modalInstance.close(a)},g.setImage=function(a){if(!(a in g.images))throw"Invalid image.";g.loading=!0,f&&f.start();var b=g.images[a],c=g.getImageUrl(b),d=function(d){d=d||{},g.index=d.index||a,g.image=d.image||b,g.imageUrl=d.imageUrl||c,g.imageCaption=d.imageCaption||g.getImageCaption(b),g.loading=!1,f&&f.complete()};g.isVideo(b)?d():e.load(c).then(function(){d()},function(){d({imageUrl:"//:0",imageCaption:"Failed to load image"})})},g.firstImage=function(){g.setImage(0)},g.prevImage=function(){g.setImage((g.index-1+g.images.length)%g.images.length)},g.nextImage=function(){g.setImage((g.index+1)%g.images.length)},g.lastImage=function(){g.setImage(g.images.length-1)},g.setImages=function(a){g.images=a,g.setImage(g.index)},a.bind("keydown",function(a){if(g.keyboardNavEnabled){var b=null;switch(a.which){case 39:b="nextImage";break;case 37:b="prevImage"}null!==b&&-1===["input","textarea"].indexOf(a.target.tagName.toLowerCase())&&(d(function(){g[b]()}),a.preventDefault())}}),g}]}),angular.module("bootstrapLightbox").directive("lightboxSrc",["$window","ImageLoader","Lightbox",function(a,b,c){var d=function(a,b){var c=a.width,d=a.height,e=a.minWidth,f=a.minHeight,g=a.maxWidth,h=a.maxHeight,i=c,j=d;if(b){var k=Math.min(g/c,h/d),l=Math.round(c*k),m=Math.round(d*k);i=Math.max(e,l),j=Math.max(f,m)}else e>c&&f>d?c/d>g/h?(j=f,i=Math.round(c*f/d)):(i=e,j=Math.round(d*e/c)):e>c?(i=e,j=Math.round(d*e/c)):f>d&&(j=f,i=Math.round(c*f/d)),c>g&&d>h?c/d>g/h?(i=g,j=Math.round(d*g/c)):(j=h,i=Math.round(c*h/d)):c>g?(i=g,j=Math.round(d*g/c)):d>h&&(j=h,i=Math.round(c*h/d));return{width:i||0,height:j||0}},e=0,f=0;return{link:function(g,h,i){var j=function(){var b=a.innerWidth,g=a.innerHeight,i=c.calculateImageDimensionLimits({windowWidth:b,windowHeight:g,imageWidth:e,imageHeight:f}),j=d(angular.extend({width:e,height:f,minWidth:1,minHeight:1,maxWidth:3e3,maxHeight:3e3},i),c.fullScreenMode),k=c.calculateModalDimensions({windowWidth:b,windowHeight:g,imageDisplayWidth:j.width,imageDisplayHeight:j.height});h.css({width:j.width+"px",height:j.height+"px"}),angular.element(document.querySelector(".lightbox-modal .modal-dialog")).css({width:k.width+"px"}),angular.element(document.querySelector(".lightbox-modal .modal-content")).css({height:k.height+"px"})};g.$watch(function(){return i.lightboxSrc},function(a){c.isVideo(c.image)?(e=1280,f=720,j(),h[0].src=a):(h[0].src="//:0",b.load(a).then(function(b){e=b.naturalWidth,f=b.naturalHeight,j(),h[0].src=a},function(){e=0,f=0,j()}))}),angular.element(a).on("resize",j)}}}]); |
{ | ||
"name": "angular-bootstrap-lightbox", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "An AngularJS lightbox built using UI Bootstrap Modal.", | ||
@@ -24,4 +24,4 @@ "keywords": [ | ||
"grunt-contrib-htmlmin": "^0.4.0", | ||
"grunt-contrib-jshint": "^0.11.2", | ||
"grunt-contrib-uglify": "^0.9.1", | ||
"grunt-contrib-jshint": "^0.11.3", | ||
"grunt-contrib-uglify": "^0.9.2", | ||
"grunt-jsdoc-to-markdown": "^1.1.1", | ||
@@ -28,0 +28,0 @@ "grunt-ng-annotate": "^1.0.1", |
@@ -246,2 +246,4 @@ /** | ||
* current image. | ||
* @param {Object} modalParams Custom params for the angular UI | ||
* bootstrap modal (in $modal.open()). | ||
* @return {Object} The created UI Bootstrap modal instance. | ||
@@ -252,3 +254,3 @@ * @type {Function} | ||
*/ | ||
Lightbox.openModal = function (newImages, newIndex) { | ||
Lightbox.openModal = function (newImages, newIndex, modalParams) { | ||
Lightbox.images = newImages; | ||
@@ -258,3 +260,3 @@ Lightbox.setImage(newIndex); | ||
// store the modal instance so we can close it manually if we need to | ||
Lightbox.modalInstance = $modal.open({ | ||
Lightbox.modalInstance = $modal.open(angular.extend({ | ||
'templateUrl': Lightbox.templateUrl, | ||
@@ -268,3 +270,3 @@ 'controller': ['$scope', function ($scope) { | ||
'windowClass': 'lightbox-modal' | ||
}); | ||
}, modalParams || {})); | ||
@@ -271,0 +273,0 @@ // modal close handler |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82934
1467