add and load popper.js in child theme too

This commit is contained in:
Holger Könemann 2017-08-16 15:35:00 +02:00
parent 8de8d7c375
commit 2059f07acb
5 changed files with 24 additions and 12 deletions

View file

@ -17,5 +17,7 @@ function theme_enqueue_styles() {
$the_theme = wp_get_theme(); $the_theme = wp_get_theme();
wp_enqueue_style( 'child-understrap-styles', get_stylesheet_directory_uri() . '/css/child-theme.min.css', array(), $the_theme->get( 'Version' ) ); wp_enqueue_style( 'child-understrap-styles', get_stylesheet_directory_uri() . '/css/child-theme.min.css', array(), $the_theme->get( 'Version' ) );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'popper-scripts', get_template_directory_uri() . '/js/popper.min.js', array(), false);
wp_enqueue_script( 'child-understrap-scripts', get_stylesheet_directory_uri() . '/js/child-theme.min.js', array(), $the_theme->get( 'Version' ), true ); wp_enqueue_script( 'child-understrap-scripts', get_stylesheet_directory_uri() . '/js/child-theme.min.js', array(), $the_theme->get( 'Version' ), true );
} }

View file

@ -1,6 +1,6 @@
/**! /**!
* @fileOverview Kickass library to create and place poppers near their reference elements. * @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.11.1 * @version 1.12.1
* @license * @license
* Copyright (c) 2016 Federico Zivolo and contributors * Copyright (c) 2016 Federico Zivolo and contributors
* *
@ -873,6 +873,7 @@ function update() {
var data = { var data = {
instance: this, instance: this,
styles: {}, styles: {},
arrowStyles: {},
attributes: {}, attributes: {},
flipped: false, flipped: false,
offsets: {} offsets: {}
@ -1117,9 +1118,9 @@ function applyStyle(data) {
// they will be set as HTML attributes of the element // they will be set as HTML attributes of the element
setAttributes(data.instance.popper, data.attributes); setAttributes(data.instance.popper, data.attributes);
// if the arrow style has been computed, apply the arrow style // if arrowElement is defined and arrowStyles has some properties
if (data.offsets.arrow) { if (data.arrowElement && Object.keys(data.arrowStyles).length) {
setStyles(data.arrowElement, data.offsets.arrow); setStyles(data.arrowElement, data.arrowStyles);
} }
return data; return data;
@ -1239,9 +1240,10 @@ function computeStyle(data, options) {
'x-placement': data.placement 'x-placement': data.placement
}; };
// Update attributes and styles of `data` // Update `data` attributes, styles and arrowStyles
data.attributes = _extends({}, attributes, data.attributes); data.attributes = _extends({}, attributes, data.attributes);
data.styles = _extends({}, styles, data.styles); data.styles = _extends({}, styles, data.styles);
data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
return data; return data;
} }
@ -1314,13 +1316,15 @@ function arrow(data, options) {
var isVertical = ['left', 'right'].indexOf(placement) !== -1; var isVertical = ['left', 'right'].indexOf(placement) !== -1;
var len = isVertical ? 'height' : 'width'; var len = isVertical ? 'height' : 'width';
var side = isVertical ? 'top' : 'left'; var sideCapitalized = isVertical ? 'Top' : 'Left';
var side = sideCapitalized.toLowerCase();
var altSide = isVertical ? 'left' : 'top'; var altSide = isVertical ? 'left' : 'top';
var opSide = isVertical ? 'bottom' : 'right'; var opSide = isVertical ? 'bottom' : 'right';
var arrowElementSize = getOuterSizes(arrowElement)[len]; var arrowElementSize = getOuterSizes(arrowElement)[len];
// //
// extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction // extends keepTogether behavior making sure the popper and its
// reference have enough pixels in conjuction
// //
// top/left side // top/left side
@ -1336,7 +1340,9 @@ function arrow(data, options) {
var center = reference[side] + reference[len] / 2 - arrowElementSize / 2; var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
// Compute the sideValue using the updated popper offsets // Compute the sideValue using the updated popper offsets
var sideValue = center - getClientRect(data.offsets.popper)[side]; // take popper margin in account because we don't have this info available
var popperMarginSide = getStyleComputedProperty(data.instance.popper, 'margin' + sideCapitalized).replace('px', '');
var sideValue = center - getClientRect(data.offsets.popper)[side] - popperMarginSide;
// prevent arrowElement from being placed not contiguously to its popper // prevent arrowElement from being placed not contiguously to its popper
sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0); sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
@ -1858,7 +1864,7 @@ function inner(data) {
var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1; var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
popper[isHoriz ? 'left' : 'top'] = reference[placement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0); popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
data.placement = getOppositePlacement(placement); data.placement = getOppositePlacement(placement);
data.offsets.popper = getClientRect(popper); data.offsets.popper = getClientRect(popper);
@ -1936,6 +1942,9 @@ var modifiers = {
* '10 - 5vh + 3%' * '10 - 5vh + 3%'
* '-10px + 5vh, 5px - 6%' * '-10px + 5vh, 5px - 6%'
* ``` * ```
* > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
* > with their reference element, unfortunately, you will have to disable the `flip` modifier.
* > More on this [reading this issue](https://github.com/FezVrasta/popper.js/issues/373)
* *
* @memberof modifiers * @memberof modifiers
* @inner * @inner
@ -2198,6 +2207,7 @@ var modifiers = {
* @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper.
* @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
* @property {Object} data.styles Any CSS property defined here will be applied to the popper, it expects the JavaScript nomenclature (eg. `marginBottom`) * @property {Object} data.styles Any CSS property defined here will be applied to the popper, it expects the JavaScript nomenclature (eg. `marginBottom`)
* @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow, it expects the JavaScript nomenclature (eg. `marginBottom`)
* @property {Object} data.boundaries Offsets of the popper boundaries * @property {Object} data.boundaries Offsets of the popper boundaries
* @property {Object} data.offsets The measurements of popper, reference and arrow elements. * @property {Object} data.offsets The measurements of popper, reference and arrow elements.
* @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values

2
js/popper.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "understrap-child", "name": "understrap-child",
"version": "0.3.3.2", "version": "0.3.4",
"description": "Basic Child Theme for UnderStrap Theme Framework: https://github.com/holger1411/understrap", "description": "Basic Child Theme for UnderStrap Theme Framework: https://github.com/holger1411/understrap",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View file

@ -5,7 +5,7 @@
Author: Holger Koenemann Author: Holger Koenemann
Author URI: http://www.holgerkoenemann.de Author URI: http://www.holgerkoenemann.de
Template: understrap Template: understrap
Version: 0.3.3.2 Version: 0.3.4
License: GNU General Public License v2 or later License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: understrap-child Text Domain: understrap-child