vendor/assets/javascripts/uikit/components/lightbox.js in uikit2-rails-0.1.9 vs vendor/assets/javascripts/uikit/components/lightbox.js in uikit2-rails-0.1.10
- old
+ new
@@ -1,16 +1,16 @@
-/*! UIkit 2.26.3 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
+/*! UIkit 2.27.2 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit) {
component = addon(UIkit);
}
- if (typeof define == "function" && define.amd) { // AMD
- define("uikit-lightbox", ["uikit"], function(){
+ if (typeof define == 'function' && define.amd) { // AMD
+ define('uikit-lightbox', ['uikit'], function(){
return component || addon(UIkit);
});
}
})(function(UI){
@@ -20,13 +20,14 @@
var modal, cache = {};
UI.component('lightbox', {
defaults: {
- "group" : false,
- "duration" : 400,
- "keyboard" : true
+ allowfullscreen : true,
+ duration : 400,
+ group : false,
+ keyboard : true
},
index : 0,
items : false,
@@ -36,16 +37,16 @@
e.preventDefault();
var link = UI.$(this);
- if (!link.data("lightbox")) {
+ if (!link.data('lightbox')) {
- UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox")));
+ UI.lightbox(link, UI.Utils.options(link.attr('data-uk-lightbox')));
}
- link.data("lightbox").show(link);
+ link.data('lightbox').show(link);
});
// keyboard navigation
UI.$doc.on('keyup', function(e) {
@@ -72,24 +73,21 @@
this.index = 0;
this.siblings = [];
if (this.element && this.element.length) {
- var domSiblings = this.options.group ? UI.$([
- '[data-uk-lightbox*="'+this.options.group+'"]',
- "[data-uk-lightbox*='"+this.options.group+"']"
- ].join(',')) : this.element;
+ var domSiblings = this.options.group ? UI.$('[data-uk-lightbox*="'+this.options.group+'"]') : this.element;
domSiblings.each(function() {
var ele = UI.$(this);
siblings.push({
- 'source': ele.attr('href'),
- 'title' : ele.attr('data-title') || ele.attr('title'),
- 'type' : ele.attr("data-lightbox-type") || 'auto',
- 'link' : ele
+ source : ele.attr('href'),
+ title : ele.attr('data-title') || ele.attr('title'),
+ type : ele.attr("data-lightbox-type") || 'auto',
+ link : ele
});
});
this.index = domSiblings.index(this.element);
this.siblings = siblings;
@@ -132,21 +130,21 @@
}
item = this.siblings[index];
data = {
- "lightbox" : $this,
- "source" : item.source,
- "type" : item.type,
- "index" : index,
- "promise" : promise,
- "title" : item.title,
- "item" : item,
- "meta" : {
- "content" : '',
- "width" : null,
- "height" : null
+ lightbox : $this,
+ source : item.source,
+ type : item.type,
+ index : index,
+ promise : promise,
+ title : item.title,
+ item : item,
+ meta : {
+ content : '',
+ width : null,
+ height : null
}
};
this.index = index;
@@ -197,18 +195,18 @@
].join('');
}
// calculate width
var tmp = UI.$('<div> </div>').css({
- 'opacity' : 0,
- 'position' : 'absolute',
- 'top' : 0,
- 'left' : 0,
- 'width' : '100%',
- 'max-width' : $this.modal.dialog.css('max-width'),
- 'padding' : $this.modal.dialog.css('padding'),
- 'margin' : $this.modal.dialog.css('margin')
+ opacity : 0,
+ position : 'absolute',
+ top : 0,
+ left : 0,
+ width : '100%',
+ maxWidth : $this.modal.dialog.css('max-width'),
+ padding : $this.modal.dialog.css('padding'),
+ margin : $this.modal.dialog.css('margin')
}), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
tmp.appendTo('body').width();
maxwidth = tmp.width();
@@ -252,15 +250,15 @@
duration = 0;
}
this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
$this.modal.loader.addClass('uk-hidden');
- $this.modal.content.css({width:''}).animate({'opacity': 1}, function() {
+ $this.modal.content.css({width:''}).animate({opacity: 1}, function() {
$this.modal.closer.removeClass('uk-hidden');
});
- $this.modal.data({'mwidth': w, 'mheight': h});
+ $this.modal.data({mwidth: w, mheight: h});
});
},
next: function() {
this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
@@ -276,20 +274,20 @@
UI.plugin('lightbox', 'image', {
init: function(lightbox) {
- lightbox.on("showitem.uk.lightbox", function(e, data){
+ lightbox.on('showitem.uk.lightbox', function(e, data){
if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
var resolve = function(source, width, height) {
data.meta = {
- "content" : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
- "width" : width,
- "height" : height
+ content : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
+ width : width,
+ height : height
};
data.type = 'image';
data.promise.resolve();
@@ -316,26 +314,26 @@
}
});
}
});
- UI.plugin("lightbox", "youtube", {
+ UI.plugin('lightbox', 'youtube', {
init: function(lightbox) {
var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
youtubeRegExpShort = /youtu\.be\/(.*)/;
- lightbox.on("showitem.uk.lightbox", function(e, data){
+ lightbox.on('showitem.uk.lightbox', function(e, data){
var id, matches, resolve = function(id, width, height) {
data.meta = {
- 'content': '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"></iframe>',
- 'width': width,
- 'height': height
+ content: '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
+ width: width,
+ height: height
};
data.type = 'iframe';
data.promise.resolve();
@@ -387,25 +385,25 @@
});
}
});
- UI.plugin("lightbox", "vimeo", {
+ UI.plugin('lightbox', 'vimeo', {
init: function(lightbox) {
var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
- lightbox.on("showitem.uk.lightbox", function(e, data){
+ lightbox.on('showitem.uk.lightbox', function(e, data){
var id, resolve = function(id, width, height) {
data.meta = {
- 'content': '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"></iframe>',
- 'width': width,
- 'height': height
+ content: '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
+ width: width,
+ height: height
};
data.type = 'iframe';
data.promise.resolve();
@@ -417,11 +415,11 @@
if(!cache[id]) {
UI.$.ajax({
type : 'GET',
- url : 'http://vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
+ url : '//vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
jsonp : 'callback',
dataType : 'jsonp',
success : function(data) {
cache[id] = {width:data.width, height:data.height};
resolve(id, cache[id].width, cache[id].height);
@@ -436,23 +434,23 @@
}
});
}
});
- UI.plugin("lightbox", "video", {
+ UI.plugin('lightbox', 'video', {
init: function(lightbox) {
- lightbox.on("showitem.uk.lightbox", function(e, data){
+ lightbox.on('showitem.uk.lightbox', function(e, data){
var resolve = function(source, width, height) {
data.meta = {
- 'content': '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
- 'width': width,
- 'height': height
+ content: '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
+ width: width,
+ height: height
};
data.type = 'video';
data.promise.resolve();
@@ -482,22 +480,22 @@
});
}
});
- UIkit.plugin("lightbox", "iframe", {
+ UIkit.plugin('lightbox', 'iframe', {
init: function (lightbox) {
- lightbox.on("showitem.uk.lightbox", function (e, data) {
+ lightbox.on('showitem.uk.lightbox', function (e, data) {
var resolve = function (source, width, height) {
data.meta = {
- 'content': '<iframe class="uk-responsive-width" src="' + source + '" width="' + width + '" height="' + height + '"></iframe>',
- 'width': width,
- 'height': height
+ content: '<iframe class="uk-responsive-width" src="' + source + '" width="' + width + '" height="' + height + '"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
+ width: width,
+ height: height
};
data.type = 'iframe';
data.promise.resolve();
@@ -534,19 +532,19 @@
modal.loader = modal.find('.uk-modal-spinner:first');
modal.closer = modal.find('.uk-close.uk-close-alt');
modal.modal = UI.modal(modal, {modal:false});
// next / previous
- modal.on("swipeRight swipeLeft", function(e) {
+ modal.on('swipeRight swipeLeft', function(e) {
modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
- }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){
+ }).on('click', '[data-lightbox-previous], [data-lightbox-next]', function(e){
e.preventDefault();
modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
});
// destroy content on modal hide
- modal.on("hide.uk.modal", function(e) {
+ modal.on('hide.uk.modal', function(e) {
modal.content.html('');
});
var resizeCache = {w: window.innerWidth, h:window.innerHeight};
@@ -572,13 +570,13 @@
var group = [], o;
items.forEach(function(item) {
group.push(UI.$.extend({
- 'source' : '',
- 'title' : '',
- 'type' : 'auto',
- 'link' : false
+ source : '',
+ title : '',
+ type : 'auto',
+ link : false
}, (typeof(item) == 'string' ? {'source': item} : item)));
});
o = UI.lightbox(UI.$.extend({}, options, {'group':group}));