templates: Update to Featherlight 1.7.12.

This commit is contained in:
Bradley Sepos 2018-01-26 17:30:16 -05:00
parent 2d058ef44c
commit 61d85446ff
No known key found for this signature in database
GPG Key ID: DEADE2F57D42D9C7
7 changed files with 179 additions and 72 deletions

View File

@ -1,8 +0,0 @@
/**
* Featherlight - ultra slim jQuery lightbox
* Version 1.4.0 - http://noelboss.github.io/featherlight/
*
* Copyright 2016, Noël Raoul Bossart (http://www.noelboss.com)
* MIT Licensed.
**/
@media all{.featherlight{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483647;text-align:center;white-space:nowrap;cursor:pointer;background:#333;background:rgba(0,0,0,0)}.featherlight:last-of-type{background:rgba(0,0,0,.8)}.featherlight:before{content:'';display:inline-block;height:100%;vertical-align:middle;margin-right:-.25em}.featherlight .featherlight-content{position:relative;text-align:left;vertical-align:middle;display:inline-block;overflow:auto;padding:25px 25px 0;border-bottom:25px solid transparent;margin-left:5%;margin-right:5%;max-height:95%;background:#fff;cursor:auto;white-space:normal}.featherlight .featherlight-inner{display:block}.featherlight .featherlight-close-icon{position:absolute;z-index:9999;top:0;right:0;line-height:25px;width:25px;cursor:pointer;text-align:center;font-family:Arial,sans-serif;background:#fff;background:rgba(255,255,255,.3);color:#000}.featherlight .featherlight-image{width:100%}.featherlight-iframe .featherlight-content{border-bottom:0;padding:0}.featherlight iframe{border:0}}@media only screen and (max-width:1024px){.featherlight .featherlight-content{margin-left:10px;margin-right:10px;max-height:98%;padding:10px 10px 0;border-bottom:10px solid transparent}}

View File

@ -1,11 +1,16 @@
/** /**
* Featherlight ultra slim jQuery lightbox * Featherlight ultra slim jQuery lightbox
* Version 1.4.0 - http://noelboss.github.io/featherlight/ * Version 1.7.12 - http://noelboss.github.io/featherlight/
* *
* Copyright 2016, Noël Raoul Bossart (http://www.noelboss.com) * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com)
* MIT Licensed. * MIT Licensed.
**/ **/
@media all { @media all {
html.with-featherlight {
/* disable global scrolling when featherlights are visible */
overflow: hidden;
}
.featherlight { .featherlight {
display: none; display: none;
@ -38,7 +43,6 @@
display: inline-block; display: inline-block;
height: 100%; height: 100%;
vertical-align: middle; vertical-align: middle;
margin-right: -0.25em;
} }
.featherlight .featherlight-content { .featherlight .featherlight-content {
@ -74,6 +78,13 @@
display: block; display: block;
} }
/* don't show these though */
.featherlight script.featherlight-inner,
.featherlight link.featherlight-inner,
.featherlight style.featherlight-inner {
display: none;
}
.featherlight .featherlight-close-icon { .featherlight .featherlight-close-icon {
/* position: centering vertical and horizontal */ /* position: centering vertical and horizontal */
position: absolute; position: absolute;
@ -92,8 +103,15 @@
background: #fff; /* Set the background in case it overlaps the content */ background: #fff; /* Set the background in case it overlaps the content */
background: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.3);
color: #000; color: #000;
border: none;
padding: 0;
} }
/* See http://stackoverflow.com/questions/16077341/how-to-reset-all-default-styles-of-the-html5-button-element */
.featherlight .featherlight-close-icon::-moz-focus-inner {
border: 0;
padding: 0;
}
.featherlight .featherlight-image { .featherlight .featherlight-image {
/* styling */ /* styling */
@ -105,23 +123,38 @@
/* removed the border for image croping since iframe is edge to edge */ /* removed the border for image croping since iframe is edge to edge */
border-bottom: 0; border-bottom: 0;
padding: 0; padding: 0;
-webkit-overflow-scrolling: touch;
overflow-y: scroll;
} }
.featherlight iframe { .featherlight iframe {
/* styling */ /* styling */
border: none; border: none;
} }
.featherlight * { /* See https://github.com/noelboss/featherlight/issues/42 */
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
} }
/* handling phones and small screens */ /* handling phones and small screens */
@media only screen and (max-width: 1024px) { @media only screen and (max-width: 1024px) {
.featherlight .featherlight-content { .featherlight .featherlight-content {
/* dimensions: maximize lightbox with for small screens */ /* dimensions: maximize lightbox with for small screens */
margin-left: 10px; margin-left: 0;
margin-right: 10px; margin-right: 0;
max-height: 98%; max-height: 98%;
padding: 10px 10px 0; padding: 10px 10px 0;
border-bottom: 10px solid transparent; border-bottom: 10px solid transparent;
} }
} }
/* hide non featherlight items when printing */
@media print {
html.with-featherlight > * > :not(.featherlight) {
display: none;
}
}

View File

@ -0,0 +1,8 @@
/**
* Featherlight - ultra slim jQuery lightbox
* Version 1.7.12 - http://noelboss.github.io/featherlight/
*
* Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com)
* MIT Licensed.
**/
@media all{html.with-featherlight{overflow:hidden}.featherlight{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483647;text-align:center;white-space:nowrap;cursor:pointer;background:#333;background:rgba(0,0,0,0)}.featherlight:last-of-type{background:rgba(0,0,0,.8)}.featherlight:before{content:'';display:inline-block;height:100%;vertical-align:middle}.featherlight .featherlight-content{position:relative;text-align:left;vertical-align:middle;display:inline-block;overflow:auto;padding:25px 25px 0;border-bottom:25px solid transparent;margin-left:5%;margin-right:5%;max-height:95%;background:#fff;cursor:auto;white-space:normal}.featherlight .featherlight-inner{display:block}.featherlight link.featherlight-inner,.featherlight script.featherlight-inner,.featherlight style.featherlight-inner{display:none}.featherlight .featherlight-close-icon{position:absolute;z-index:9999;top:0;right:0;line-height:25px;width:25px;cursor:pointer;text-align:center;font-family:Arial,sans-serif;background:#fff;background:rgba(255,255,255,.3);color:#000;border:0;padding:0}.featherlight .featherlight-close-icon::-moz-focus-inner{border:0;padding:0}.featherlight .featherlight-image{width:100%}.featherlight-iframe .featherlight-content{border-bottom:0;padding:0;-webkit-overflow-scrolling:touch;overflow-y:scroll}.featherlight iframe{border:0}.featherlight *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}}@media only screen and (max-width:1024px){.featherlight .featherlight-content{margin-left:0;margin-right:0;max-height:98%;padding:10px 10px 0;border-bottom:10px solid transparent}}@media print{html.with-featherlight>*>:not(.featherlight){display:none}}

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
/** /**
* Featherlight - ultra slim jQuery lightbox * Featherlight - ultra slim jQuery lightbox
* Version 1.4.0 - http://noelboss.github.io/featherlight/ * Version 1.7.12 - http://noelboss.github.io/featherlight/
* *
* Copyright 2016, Noël Raoul Bossart (http://www.noelboss.com) * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com)
* MIT Licensed. * MIT Licensed.
**/ **/
(function($) { (function($) {
@ -12,7 +12,10 @@
if('console' in window){ window.console.info('Too much lightness, Featherlight needs jQuery.'); } if('console' in window){ window.console.info('Too much lightness, Featherlight needs jQuery.'); }
return; return;
} }
if($.fn.jquery.match(/-ajax/)) {
if('console' in window){ window.console.info('Featherlight needs regular jQuery, not the slim version.'); }
return;
}
/* Featherlight is exported as $.featherlight. /* Featherlight is exported as $.featherlight.
It is a function used to open a featherlight lightbox. It is a function used to open a featherlight lightbox.
@ -54,20 +57,38 @@
return opened; return opened;
}; };
// structure({iframeMinHeight: 44, foo: 0}, 'iframe') // Removes keys of `set` from `obj` and returns the removed key/values.
// #=> {min-height: 44} function slice(obj, set) {
var structure = function(obj, prefix) { var r = {};
var result = {}, for (var key in obj) {
if (key in set) {
r[key] = obj[key];
delete obj[key];
}
}
return r;
}
// NOTE: List of available [iframe attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).
var iFrameAttributeSet = {
allowfullscreen: 1, frameborder: 1, height: 1, longdesc: 1, marginheight: 1, marginwidth: 1,
name: 1, referrerpolicy: 1, scrolling: 1, sandbox: 1, src: 1, srcdoc: 1, width: 1
};
// Converts camelCased attributes to dasherized versions for given prefix:
// parseAttrs({hello: 1, hellFrozeOver: 2}, 'hell') => {froze-over: 2}
function parseAttrs(obj, prefix) {
var attrs = {},
regex = new RegExp('^' + prefix + '([A-Z])(.*)'); regex = new RegExp('^' + prefix + '([A-Z])(.*)');
for (var key in obj) { for (var key in obj) {
var match = key.match(regex); var match = key.match(regex);
if (match) { if (match) {
var dasherized = (match[1] + match[2].replace(/([A-Z])/g, '-$1')).toLowerCase(); var dasherized = (match[1] + match[2].replace(/([A-Z])/g, '-$1')).toLowerCase();
result[dasherized] = obj[key]; attrs[dasherized] = obj[key];
} }
} }
return result; return attrs;
}; }
/* document wide key handler */ /* document wide key handler */
var eventMap = { keyup: 'onKeyUp', resize: 'onResize' }; var eventMap = { keyup: 'onKeyUp', resize: 'onResize' };
@ -136,9 +157,9 @@
$background = $(self.background || [ $background = $(self.background || [
'<div class="'+css+'-loading '+css+'">', '<div class="'+css+'-loading '+css+'">',
'<div class="'+css+'-content">', '<div class="'+css+'-content">',
'<span class="'+css+'-close-icon '+ self.namespace + '-close">', '<button class="'+css+'-close-icon '+ self.namespace + '-close" aria-label="Close">',
self.closeIcon, self.closeIcon,
'</span>', '</button>',
'<div class="'+self.namespace+'-inner">' + self.loading + '</div>', '<div class="'+self.namespace+'-inner">' + self.loading + '</div>',
'</div>', '</div>',
'</div>'].join('')), '</div>'].join('')),
@ -148,6 +169,9 @@
/* close when click on background/anywhere/null or closebox */ /* close when click on background/anywhere/null or closebox */
self.$instance.on(self.closeTrigger+'.'+self.namespace, function(event) { self.$instance.on(self.closeTrigger+'.'+self.namespace, function(event) {
if(event.isDefaultPrevented()) {
return;
}
var $target = $(event.target); var $target = $(event.target);
if( ('background' === self.closeOnClick && $target.is('.'+self.namespace)) if( ('background' === self.closeOnClick && $target.is('.'+self.namespace))
|| 'anywhere' === self.closeOnClick || 'anywhere' === self.closeOnClick
@ -216,25 +240,22 @@
/* sets the content of $instance to $content */ /* sets the content of $instance to $content */
setContent: function($content){ setContent: function($content){
var self = this; this.$instance.removeClass(this.namespace+'-loading');
/* we need a special class for the iframe */
if($content.is('iframe') || $('iframe', $content).length > 0){
self.$instance.addClass(self.namespace+'-iframe');
}
self.$instance.removeClass(self.namespace+'-loading'); /* we need a special class for the iframe */
this.$instance.toggleClass(this.namespace+'-iframe', $content.is('iframe'));
/* replace content by appending to existing one before it is removed /* replace content by appending to existing one before it is removed
this insures that featherlight-inner remain at the same relative this insures that featherlight-inner remain at the same relative
position to any other items added to featherlight-content */ position to any other items added to featherlight-content */
self.$instance.find('.'+self.namespace+'-inner') this.$instance.find('.'+this.namespace+'-inner')
.not($content) /* excluded new content, important if persisted */ .not($content) /* excluded new content, important if persisted */
.slice(1).remove().end() /* In the unexpected event where there are many inner elements, remove all but the first one */ .slice(1).remove().end() /* In the unexpected event where there are many inner elements, remove all but the first one */
.replaceWith($.contains(self.$instance[0], $content[0]) ? '' : $content); .replaceWith($.contains(this.$instance[0], $content[0]) ? '' : $content);
self.$content = $content.addClass(self.namespace+'-inner'); this.$content = $content.addClass(this.namespace+'-inner');
return self; return this;
}, },
/* opens the lightbox. "this" contains $instance with the lightbox, and with the config. /* opens the lightbox. "this" contains $instance with the lightbox, and with the config.
@ -305,11 +326,13 @@
/* Reset apparent image size first so container grows */ /* Reset apparent image size first so container grows */
this.$content.css('width', '').css('height', ''); this.$content.css('width', '').css('height', '');
/* Calculate the worst ratio so that dimensions fit */ /* Calculate the worst ratio so that dimensions fit */
/* Note: -1 to avoid rounding errors */
var ratio = Math.max( var ratio = Math.max(
w / parseInt(this.$content.parent().css('width'),10), w / (this.$content.parent().width()-1),
h / parseInt(this.$content.parent().css('height'),10)); h / (this.$content.parent().height()-1));
/* Resize content */ /* Resize content */
if (ratio > 1) { if (ratio > 1) {
ratio = h / Math.floor(h / ratio); /* Round ratio down so height calc works */
this.$content.css('width', '' + w / ratio + 'px').css('height', '' + h / ratio + 'px'); this.$content.css('width', '' + w / ratio + 'px').css('height', '' + h / ratio + 'px');
} }
} }
@ -341,7 +364,7 @@
process: function(elem) { return this.persist !== false ? $(elem) : $(elem).clone(true); } process: function(elem) { return this.persist !== false ? $(elem) : $(elem).clone(true); }
}, },
image: { image: {
regex: /\.(png|jpg|jpeg|gif|tiff|bmp|svg)(\?\S*)?$/i, regex: /\.(png|jpg|jpeg|gif|tiff?|bmp|svg)(\?\S*)?$/i,
process: function(url) { process: function(url) {
var self = this, var self = this,
deferred = $.Deferred(), deferred = $.Deferred(),
@ -379,10 +402,13 @@
iframe: { iframe: {
process: function(url) { process: function(url) {
var deferred = new $.Deferred(); var deferred = new $.Deferred();
var $content = $('<iframe/>') var $content = $('<iframe/>');
.hide() var css = parseAttrs(this, 'iframe');
var attrs = slice(css, iFrameAttributeSet);
$content.hide()
.attr('src', url) .attr('src', url)
.css(structure(this, 'iframe')) .attr(attrs)
.css(css)
.on('load', function() { deferred.resolve($content.show()); }) .on('load', function() { deferred.resolve($content.show()); })
// We can't move an <iframe> and avoid reloading it, // We can't move an <iframe> and avoid reloading it,
// so let's put it in place ourselves right now: // so let's put it in place ourselves right now:
@ -412,7 +438,7 @@
if ($.inArray(name, Klass.functionAttributes) >= 0) { /* jshint -W054 */ if ($.inArray(name, Klass.functionAttributes) >= 0) { /* jshint -W054 */
val = new Function(val); /* jshint +W054 */ val = new Function(val); /* jshint +W054 */
} else { } else {
try { val = $.parseJSON(val); } try { val = JSON.parse(val); }
catch(e) {} catch(e) {}
} }
config[name] = val; config[name] = val;
@ -457,24 +483,29 @@
var namespace = config.namespace || Klass.defaults.namespace, var namespace = config.namespace || Klass.defaults.namespace,
tempConfig = $.extend({}, Klass.defaults, Klass.readElementConfig($source[0], namespace), config), tempConfig = $.extend({}, Klass.defaults, Klass.readElementConfig($source[0], namespace), config),
sharedPersist; sharedPersist;
var handler = function(event) {
$source.on(tempConfig.openTrigger+'.'+tempConfig.namespace, tempConfig.filter, function(event) { var $target = $(event.currentTarget);
/* ... since we might as well compute the config on the actual target */ /* ... since we might as well compute the config on the actual target */
var elemConfig = $.extend( var elemConfig = $.extend(
{$source: $source, $currentTarget: $(this)}, {$source: $source, $currentTarget: $target},
Klass.readElementConfig($source[0], tempConfig.namespace), Klass.readElementConfig($source[0], tempConfig.namespace),
Klass.readElementConfig(this, tempConfig.namespace), Klass.readElementConfig(event.currentTarget, tempConfig.namespace),
config); config);
var fl = sharedPersist || $(this).data('featherlight-persisted') || new Klass($content, elemConfig); var fl = sharedPersist || $target.data('featherlight-persisted') || new Klass($content, elemConfig);
if(fl.persist === 'shared') { if(fl.persist === 'shared') {
sharedPersist = fl; sharedPersist = fl;
} else if(fl.persist !== false) { } else if(fl.persist !== false) {
$(this).data('featherlight-persisted', fl); $target.data('featherlight-persisted', fl);
}
if (elemConfig.$currentTarget.blur) {
elemConfig.$currentTarget.blur(); // Otherwise 'enter' key might trigger the dialog again
} }
elemConfig.$currentTarget.blur(); // Otherwise 'enter' key might trigger the dialog again
fl.open(event); fl.open(event);
}); };
return $source;
$source.on(tempConfig.openTrigger+'.'+tempConfig.namespace, tempConfig.filter, handler);
return handler;
}, },
current: function() { current: function() {
@ -505,14 +536,13 @@
}); });
/* If a click propagates to the document level, then we have an item that was added later on */ /* If a click propagates to the document level, then we have an item that was added later on */
$(document).on('click', Klass.autoBind, function(evt) { $(document).on('click', Klass.autoBind, function(evt) {
if (evt.isDefaultPrevented() || evt.namespace === 'featherlight') { if (evt.isDefaultPrevented()) {
return; return;
} }
evt.preventDefault();
/* Bind featherlight */ /* Bind featherlight */
Klass.attach($(evt.currentTarget)); var handler = Klass.attach($(evt.currentTarget));
/* Click again; this time our binding will catch it */ /* Dispatch event directly */
$(evt.target).trigger('click.featherlight'); handler(evt);
}); });
} }
}, },
@ -532,6 +562,48 @@
} }
}, },
beforeOpen: function(_super, event) {
// Used to disable scrolling
$(document.documentElement).addClass('with-featherlight');
// Remember focus:
this._previouslyActive = document.activeElement;
// Disable tabbing:
// See http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
this._$previouslyTabbable = $("a, input, select, textarea, iframe, button, iframe, [contentEditable=true]")
.not('[tabindex]')
.not(this.$instance.find('button'));
this._$previouslyWithTabIndex = $('[tabindex]').not('[tabindex="-1"]');
this._previousWithTabIndices = this._$previouslyWithTabIndex.map(function(_i, elem) {
return $(elem).attr('tabindex');
});
this._$previouslyWithTabIndex.add(this._$previouslyTabbable).attr('tabindex', -1);
if (document.activeElement.blur) {
document.activeElement.blur();
}
return _super(event);
},
afterClose: function(_super, event) {
var r = _super(event);
// Restore focus
var self = this;
this._$previouslyTabbable.removeAttr('tabindex');
this._$previouslyWithTabIndex.each(function(i, elem) {
$(elem).attr('tabindex', self._previousWithTabIndices[i]);
});
this._previouslyActive.focus();
// Restore scroll
if(Featherlight.opened().length === 0) {
$(document.documentElement).removeClass('with-featherlight');
}
return r;
},
onResize: function(_super, event){ onResize: function(_super, event){
this.resize(this.$content.naturalWidth, this.$content.naturalHeight); this.resize(this.$content.naturalWidth, this.$content.naturalHeight);
return _super(event); return _super(event);
@ -539,6 +611,7 @@
afterContent: function(_super, event){ afterContent: function(_super, event){
var r = _super(event); var r = _super(event);
this.$instance.find('[autofocus]:not([disabled])').focus();
this.onResize(event); this.onResize(event);
return r; return r;
} }
@ -549,7 +622,8 @@
/* bind jQuery elements to trigger featherlight */ /* bind jQuery elements to trigger featherlight */
$.fn.featherlight = function($content, config) { $.fn.featherlight = function($content, config) {
return Featherlight.attach(this, $content, config); Featherlight.attach(this, $content, config);
return this;
}; };
/* bind featherlight on ready if config autoBind is set */ /* bind featherlight on ready if config autoBind is set */

File diff suppressed because one or more lines are too long

View File

@ -27,11 +27,11 @@ Template:
Styles: Styles:
- assets/css/opensans.css?2016100501 - assets/css/opensans.css?2016100501
- assets/css/ropasans.css?2016100501 - assets/css/ropasans.css?2016100501
- assets/css/vendor/featherlight/featherlight-1.4.0.min.css - assets/css/vendor/featherlight/featherlight-1.7.12.min.css
- assets/css/style.css?2016121201 - assets/css/style.css?2016121201
Scripts: Scripts:
- assets/js/vendor/jquery/jquery-2.2.3.min.js - assets/js/vendor/jquery/jquery-2.2.3.min.js
- assets/js/vendor/js-cookie/js-cookie-2.1.1.min.js - assets/js/vendor/js-cookie/js-cookie-2.1.1.min.js
- assets/js/vendor/featherlight/featherlight-1.4.0.min.js - assets/js/vendor/featherlight/featherlight-1.7.12.min.js
- assets/js/scripts.js?2016111901 - assets/js/scripts.js?2016111901
... ...