Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyshab committed May 17, 2020
1 parent ff4c172 commit 3c8a212
Show file tree
Hide file tree
Showing 70 changed files with 4,747 additions and 516 deletions.
1,324 changes: 1,323 additions & 1 deletion dist/js/app.js

Large diffs are not rendered by default.

966 changes: 965 additions & 1 deletion dist/js/customize-controls.js

Large diffs are not rendered by default.

117 changes: 116 additions & 1 deletion dist/js/customize-preview.js
Original file line number Diff line number Diff line change
@@ -1 +1,116 @@
var taprootFooter=document.querySelector(".app-footer");if(taprootFooter.classList.contains("app-footer--has-fixed")){var taprootFooterObserver=new ResizeObserver(function(){window.dispatchEvent(new Event("resize"))});taprootFooterObserver.observe(taprootFooter)}function taprootFontStyles(e){var t=e.split("|"),r={},n=jQuery.noConflict();return 0<=n.inArray("bold",t)&&(r["font-weight"]="bold"),0<=n.inArray("italic",t)&&(r["font-style"]="italic"),0<=n.inArray("underline",t)&&(r["text-decoration"]="underline"),0<=n.inArray("uppercase",t)?r["text-transform"]="uppercase":0<=n.inArray("capitalize",t)&&(r["text-transform"]="capitalize"),r}function getFontFamily(e){return"default"!==e&&e?e.includes('"')?e:'"'+e+'"':"unset"}function getMobileScreen(e="default"){return"never"!==e&&e}function getDesktopScreen(e="default"){var t={never:"default",mobile:"tablet-and-up","tablet-and-under":"desktop",always:!1};return!!t[e]&&t[e]}function getPaddingFromWidth(e,t=!1){var r=(100-(e=e.replace(/[^0-9]/g,"")))/2;return t&&(r+=t),r}function maybeConvertToEm(e){return!!e&&(e.includes("px")||e.includes("%")||e.includes("em")?e:e+"em")}
/**
* Fixed Footer Monitor
*
* This file handles the JavaScript for detecting changes in the height
* of the footer when "fixed footer" is enabled. This currently only works
* in Chrome. There is a polyfill, that can be added for advanced support.
*
* @package Taproot
* @author Sky Shabatura <[email protected]>
* @copyright 2020 Sky Shabatura
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
* @link https://taproot-theme.com
*/
var taprootFooter = document.querySelector('.app-footer');
if (taprootFooter.classList.contains('app-footer--has-fixed')) {
var taprootFooterObserver = new ResizeObserver(function () {
window.dispatchEvent(new Event('resize'));
});
taprootFooterObserver.observe(taprootFooter);
}

/**
* Utility functions for use in customize preview js.
*
* @package Taproot
* @author Sky Shabatura <[email protected]>
* @copyright 2020 Sky Shabatura
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
*/

// Build font style from our font style control values.
function taprootFontStyles( value ) {
value = value.split( '|' );
let styles = {};

styles['font-weight'] = ( value.includes( 'bold' ) ) ? 'bold' : 'normal';
styles['font-style'] = ( value.includes( 'italic' ) ) ? 'italic' : 'normal';
styles['text-decoration'] = ( value.includes( 'underline' ) ) ? 'underline' : 'none';

if( value.includes( 'uppercase' ) ) {
styles['text-transform'] = 'uppercase';
}
else if( value.includes( 'capitalize' ) ) {
styles['text-transform'] = 'capitalize';
}
else {
styles['text-transform'] = 'none';
}

return styles;
}

// Get font family.
// Adds quotes if needed. Checks if "default" is set, and returns unset if so.
function getFontFamily( font ) {

if( 'default' === font || ! font ) {
return 'unset';
}
else if( font.includes( '"' ) ) {
return font;
}
else {
return '"' + font + '"';
}
}

// Get mobile screen from setting value.
function getMobileScreen( screen = 'default' ) {
return ( 'never' === screen ) ? false : screen;
}

// Get Desktop screen from mobile setting value.
function getDesktopScreen( screen = 'default' ) {

var screens = {
'never': 'default',
'mobile': 'tablet-and-up',
'tablet-and-under': 'desktop',
'always': false
};

return ( screens[screen] ) ? screens[screen] : false;
}

// Calculate padding from a width.
function getPaddingFromWidth( width, unit = false ) {

width = width.replace(/[^0-9]/g,'');
var padding = (100 - width) / 2;

if( unit ) {
padding += unit;
}

return padding;
}

// Maybe convert unitless value to em?
function maybeConvertToEm( value ) {

// If nothing is set, bail
if( ! value ) {
return false;
}

// If a unit is set, return value
if( value.includes( 'px' ) || value.includes( '%' ) || value.includes( 'em' ) ) {
return value;
}

// Otherwise, add 'em'
else {
return value + 'em';
}
}
952 changes: 951 additions & 1 deletion dist/js/editor.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"/dist/js/app.js": "/dist/js/app.js?id=4aae7780209050c34139",
"/dist/css/theme.css": "/dist/css/theme.css?id=abf45862c4090fa66218",
"/dist/css/editor.css": "/dist/css/editor.css?id=f0d5c152e7698b659101",
"/dist/css/customize-controls.css": "/dist/css/customize-controls.css?id=2513101c36a23706437e",
"/dist/js/app.js.map": "/dist/js/app.js.map?id=a3fd42acabb780318690",
"/dist/css/theme.css.map": "/dist/css/theme.css.map?id=2de0adf8bb070dd5bff2",
"/dist/css/editor.css.map": "/dist/css/editor.css.map?id=d3dd28c687efcae96d48",
"/dist/css/customize-controls.css.map": "/dist/css/customize-controls.css.map?id=03552549776a680d4072",
"/dist/js/customize-controls.js": "/dist/js/customize-controls.js?id=dd126f33dda7bbe4e303",
"/dist/js/customize-controls.js.map": "/dist/js/customize-controls.js.map?id=27ccf3d23c1e1b960d42",
"/dist/js/editor.js": "/dist/js/editor.js?id=cfdd34af741a35cb8d02",
"/dist/js/editor.js.map": "/dist/js/editor.js.map?id=bb1f515357f4df678fc6",
"/dist/js/customize-preview.js": "/dist/js/customize-preview.js?id=3688fb6519809dc80bd8"
}
7 changes: 3 additions & 4 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @link https://taproot-theme.com
*/


import './app/header.js';
import './app/footer.js';
import './app/nav-menus.js';
import '../../app/Components/Header/assets/js/header.js';
import '../../app/Components/Footer/assets/js/footer.js';
import '../../app/Components/Navigation/assets/js/nav-menus.js';
1 change: 1 addition & 0 deletions resources/js/customize-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ import './customize-controls/Color.js';
import './customize-controls/Range.js';
import './customize-controls/FontStyles.js';
import './customize-controls/DevicePicker.js';
import './customize-controls/Multicheck.js';
45 changes: 45 additions & 0 deletions resources/js/customize-controls/Multicheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Multicheck
*
* This file handles the JavaScript for the multicheck customizer control.
*
* @package Taproot
* @author Sky Shabatura <[email protected]>
* @copyright 2020 Sky Shabatura
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
*/

class Multicheck {

constructor() {
this.handlers();
}

handlers() {

document.querySelectorAll( '.customize-control-checkbox-multiple input[type="checkbox"]' ).forEach( cb => {
cb.addEventListener('change', (e) => {
const $this = e.target;
const control = $this.closest('.customize-control');
const checked = control.querySelectorAll( 'input[type="checkbox"]:checked' );
const input = control.querySelector( 'input[type="hidden"]' );
var list = [];

checked.forEach( check => {
list.push( check.value );
});

input.value = list.join();
input.dispatchEvent( new Event('change') );
});
});
}
}


/**
* Run on document ready
*/
document.addEventListener('DOMContentLoaded', () => {
const multicheck = new Multicheck();
});
34 changes: 14 additions & 20 deletions resources/js/customize-preview/functions-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@

// Build font style from our font style control values.
function taprootFontStyles( value ) {
var fontStyles = value.split( '|' ),
styles = {},
$ = jQuery.noConflict();
value = value.split( '|' );
let styles = {};

if ( 0 <= $.inArray( 'bold', fontStyles ) ) {
styles['font-weight'] = 'bold';
}

if ( 0 <= $.inArray( 'italic', fontStyles ) ) {
styles['font-style'] = 'italic';
}

if ( 0 <= $.inArray( 'underline', fontStyles ) ) {
styles['text-decoration'] = 'underline';
}
styles['font-weight'] = ( value.includes( 'bold' ) ) ? 'bold' : 'normal';
styles['font-style'] = ( value.includes( 'italic' ) ) ? 'italic' : 'normal';
styles['text-decoration'] = ( value.includes( 'underline' ) ) ? 'underline' : 'none';

if ( 0 <= $.inArray( 'uppercase', fontStyles ) ) {
if( value.includes( 'uppercase' ) ) {
styles['text-transform'] = 'uppercase';

} else if ( 0 <= $.inArray( 'capitalize', fontStyles ) ) {
}
else if( value.includes( 'capitalize' ) ) {
styles['text-transform'] = 'capitalize';
}
else {
styles['text-transform'] = 'none';
}

return styles;
}
Expand All @@ -39,10 +33,10 @@ function taprootFontStyles( value ) {
// Adds quotes if needed. Checks if "default" is set, and returns unset if so.
function getFontFamily( font ) {

if( 'default' === font || !font ) {
if( 'default' === font || ! font ) {
return 'unset';
}
else if( font.includes('"') ) {
else if( font.includes( '"' ) ) {
return font;
}
else {
Expand Down Expand Up @@ -90,7 +84,7 @@ function maybeConvertToEm( value ) {
}

// If a unit is set, return value
if( value.includes('px') || value.includes('%') || value.includes('em') ) {
if( value.includes( 'px' ) || value.includes( '%' ) || value.includes( 'em' ) ) {
return value;
}

Expand Down
8 changes: 2 additions & 6 deletions resources/js/editor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* Primary front-end script.
* Editor script.
*
* Primary JavaScript file. Any includes or anything imported should
* be filtered through this file and eventually saved back into the
* `/dist/js/app.js` file.
* Primary JavaScript file for theme editor functionality.
*
* @package Taproot
* @author Sky Shabatura <[email protected]>
Expand All @@ -12,6 +10,4 @@
* @link https://taproot-theme.com
*/


import './editor/sidebar/index.js';
import './editor/blocks/buttons/index.js';
Loading

0 comments on commit 3c8a212

Please sign in to comment.