Skip to content

Instantly share code, notes, and snippets.

@malles
Last active May 24, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malles/423a1eb266f169d01edc to your computer and use it in GitHub Desktop.
Save malles/423a1eb266f169d01edc to your computer and use it in GitHub Desktop.
UIkit lightbox Iframe plugin
(function () {
"use strict";
UIkit.on('beforeready.uk.dom', function () {
UIkit.plugin("lightbox", "iframe", {
init: function (lightbox) {
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
};
data.type = 'iframe';
data.promise.resolve();
};
if (data.type === 'iframe' || data.source.match(/\.(html|php)$/)) {
resolve(data.source, (lightbox.options.width || 800), (lightbox.options.height || 600));
}
});
}
});
});
}());
@malles
Copy link
Author

malles commented May 22, 2015

Make sure to add the data-lightbox-type="iframe" attribute to the lightbox!

@fordiy
Copy link

fordiy commented Nov 18, 2015

Excellent! It works!

@ji4
Copy link

ji4 commented May 24, 2016

It works! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment