first commit
This commit is contained in:
71
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/Makefile
vendored
Normal file
71
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/Makefile
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
.PHONY: help list
|
||||
.PHONY: precommit
|
||||
.PHONY: dupes comp jest phpunit test dev prod
|
||||
.PHONY: setup test
|
||||
|
||||
setup:: vendor/autoload.php
|
||||
setup:: yarn.lock
|
||||
setup:: githooks
|
||||
|
||||
test:: jest
|
||||
test:: phpunit
|
||||
|
||||
precommit:: validate-composer
|
||||
precommit:: validate-yarn
|
||||
precommit:: dupes
|
||||
precommit:: compatibility
|
||||
|
||||
# precommit
|
||||
|
||||
dupes: vendor/autoload.php
|
||||
./.make/check-duplicates.sh
|
||||
|
||||
compatibility: vendor/autoload.php
|
||||
./.make/check-compatibility.sh
|
||||
|
||||
validate-composer: composer.lock
|
||||
./.make/check-composer.sh
|
||||
|
||||
validate-yarn: yarn.lock
|
||||
./.make/check-yarn.sh
|
||||
|
||||
# Dependency managers
|
||||
|
||||
## Composer
|
||||
composer.lock: composer.json
|
||||
composer install
|
||||
touch $@
|
||||
|
||||
composer.json:
|
||||
composer init -q
|
||||
|
||||
vendor/autoload.php: composer.lock
|
||||
composer install
|
||||
touch $@
|
||||
|
||||
## Yarn
|
||||
yarn.lock: package.json
|
||||
yarn install
|
||||
touch $@
|
||||
|
||||
package.json:
|
||||
yarn init -y
|
||||
|
||||
# Setup
|
||||
|
||||
githooks:
|
||||
find .git/hooks -type l -exec rm {} \;
|
||||
find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
|
||||
|
||||
# Tests
|
||||
|
||||
jest: yarn.lock
|
||||
yarn run test
|
||||
|
||||
phpunit: vendor/autoload.php
|
||||
vendor/bin/phpunit --fail-on-warning
|
||||
|
||||
# Build
|
||||
|
||||
dev prod: yarn.lock
|
||||
yarn run build:$@
|
||||
30
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/assets.json
vendored
Normal file
30
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/assets.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"entrypoints": {
|
||||
"otgsSwitcher": {
|
||||
"js": [
|
||||
"js/otgsSwitcher.js?ver=f595bebc725685c64364025046cefaad"
|
||||
],
|
||||
"css": [
|
||||
"css/otgsSwitcher.css?ver=f595bebc725685c64364"
|
||||
]
|
||||
},
|
||||
"otgsPopoverTooltip": {
|
||||
"js": [
|
||||
"js/otgsPopoverTooltip.js?ver=c3382832d52fd68ddffa33aaedb532c3"
|
||||
],
|
||||
"css": [
|
||||
"css/otgsPopoverTooltip.css?ver=c3382832d52fd68ddffa"
|
||||
]
|
||||
},
|
||||
"otgsTableStickyHeader": {
|
||||
"js": [
|
||||
"js/otgsTableStickyHeader.js?ver=d62ecd8af1b60da03056e0fa04b2b6da"
|
||||
]
|
||||
}
|
||||
},
|
||||
"otgsPopoverTooltip.css": "css/otgsPopoverTooltip.css?ver=c3382832d52fd68ddffa",
|
||||
"otgsPopoverTooltip.js": "js/otgsPopoverTooltip.js?ver=c3382832d52fd68ddffa33aaedb532c3",
|
||||
"otgsSwitcher.css": "css/otgsSwitcher.css?ver=f595bebc725685c64364",
|
||||
"otgsSwitcher.js": "js/otgsSwitcher.js?ver=f595bebc725685c64364025046cefaad",
|
||||
"otgsTableStickyHeader.js": "js/otgsTableStickyHeader.js?ver=d62ecd8af1b60da03056e0fa04b2b6da"
|
||||
}
|
||||
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/css/otgsPopoverTooltip.css
vendored
Normal file
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/css/otgsPopoverTooltip.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.tippy-popper[x-placement^=top] .tippy-tooltip.otgs-theme .tippy-arrow{border-top:7px solid #ddd;border-right:7px solid transparent;border-left:7px solid transparent}.tippy-popper[x-placement^=top] .tippy-tooltip.otgs-theme .tippy-arrow:after{content:"";position:absolute;top:-7px;left:-6px;border-top:6px solid #fff;border-right:6px solid transparent;border-left:6px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.otgs-theme .tippy-arrow{border-bottom:7px solid #ddd;border-right:7px solid transparent;border-left:7px solid transparent}.tippy-popper[x-placement^=bottom] .tippy-tooltip.otgs-theme .tippy-arrow:after{content:"";position:absolute;bottom:-7px;left:-6px;border-bottom:6px solid #fff;border-right:6px solid transparent;border-left:6px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.otgs-theme .tippy-arrow{border-left:7px solid #ddd;border-top:7px solid transparent;border-bottom:7px solid transparent}.tippy-popper[x-placement^=left] .tippy-tooltip.otgs-theme .tippy-arrow:after{content:"";position:absolute;left:-7px;top:-6px;border-left:6px solid #fff;border-top:6px solid transparent;border-bottom:6px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.otgs-theme .tippy-arrow{border-right:7px solid #ddd;border-top:7px solid transparent;border-bottom:7px solid transparent}.tippy-popper[x-placement^=right] .tippy-tooltip.otgs-theme .tippy-arrow:after{content:"";position:absolute;right:-7px;top:-6px;border-right:6px solid #fff;border-top:6px solid transparent;border-bottom:6px solid transparent}.tippy-tooltip.otgs-theme{font-size:13px;background:#fff;border:1px solid #ddd;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.075);box-shadow:0 1px 4px rgba(0,0,0,.075);color:#444;border-radius:2px}.tippy-tooltip.otgs-theme .tippy-backdrop{background-color:#fff}.tippy-tooltip.otgs-theme .tippy-roundarrow{fill:#fff}.tippy-tooltip.otgs-theme[data-animatefill]{background-color:transparent}
|
||||
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/css/otgsSwitcher.css
vendored
Normal file
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/css/otgsSwitcher.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.otgs-switcher-input{width:0!important;min-width:0!important;height:0!important;visibility:hidden!important;margin:0!important;border:none!important}.otgs-switcher,.otgs-switcher-text-inside{cursor:pointer;display:inline-block;position:relative}.otgs-switcher-text-inside:after,.otgs-switcher:after{content:"";position:absolute;left:3px;top:2px;width:13px;height:13px;background:#fff;border-radius:90px;-webkit-transition:.3s;transition:.3s;z-index:3}.otgs-switcher-text-inside,.otgs-switcher:before{height:19px;line-height:17px;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#e0e0e0;border:1px solid #d6d6d6;display:inline-block;border-radius:100px;vertical-align:middle;font-size:11px;color:#444;-webkit-transition:background .1s linear,color .1s linear,border .1s linear;transition:background .1s linear,color .1s linear,border .1s linear;padding:0 6px 0 20px}.otgs-switcher-text-inside.otgs-switcher-md{height:25px;line-height:23px;padding:0 6px 0 26px}.otgs-switcher-text-inside.otgs-switcher-md:after{width:19px;height:19px}.otgs-switcher{padding-left:56px;margin-top:4px;min-height:19px}.otgs-switcher:before{content:attr(data-off);width:48px;position:absolute;left:0}.otgs-switcher:after{top:3px}.otgs-switcher-input:disabled+.otgs-switcher-text-inside,.otgs-switcher-input:disabled+.otgs-switcher-text-inside:after,.otgs-switcher-input:disabled+.otgs-switcher:after,.otgs-switcher-input:disabled+.otgs-switcher:before{opacity:.6}.otgs-switcher-input:checked+.otgs-switcher:before{content:attr(data-on)}.otgs-switcher-input:checked+.otgs-switcher-text-inside,.otgs-switcher-input:checked+.otgs-switcher:before{background-color:#5cb85c;border:1px solid #4eb24e;color:#fff;padding:0 20px 0 6px}.otgs-switcher-input:checked+.otgs-switcher-text-inside.otgs-switcher-md{padding:0 26px 0 6px}.otgs-switcher-input:checked+.otgs-switcher-text-inside.toolset-theme,.otgs-switcher-input:checked+.otgs-switcher.toolset-theme:before{background-color:#f15d30;border:1px solid #f04e1d}.otgs-switcher-input:checked+.otgs-switcher-text-inside.wpml-theme,.otgs-switcher-input:checked+.otgs-switcher.wpml-theme:before{background-color:#33879e;border:1px solid #2e7a8f}.otgs-switcher-input:checked+.otgs-switcher:after{left:45px;-webkit-transform:translateX(-100%);transform:translateX(-100%)}.otgs-switcher-input:checked+.otgs-switcher-text-inside:after{left:-webkit-calc(100% - 3px);left:calc(100% - 3px);-webkit-transform:translateX(-100%);transform:translateX(-100%)}
|
||||
31
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/js/otgsPopoverTooltip.js
vendored
Normal file
31
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/js/otgsPopoverTooltip.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/js/otgsSwitcher.js
vendored
Normal file
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/dist/js/otgsSwitcher.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var OTGSUI=OTGSUI||{};OTGSUI.otgsSwitcher=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}({16:function(t,e){},7:function(t,e,r){"use strict";r(16)},8:function(t,e,r){t.exports=r(7)}});
|
||||
File diff suppressed because one or more lines are too long
108
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/loader.php
vendored
Normal file
108
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/loader.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Load the shared OTGS UI library, on demand.
|
||||
*
|
||||
* =================
|
||||
* Usage
|
||||
* =================
|
||||
* $vendor_path = [ path to the root of your relative vendor directory housing this repository, no training slash ]
|
||||
* $vendor_url = [ URL of the root of your relative vendor directory housing this repository, no trailing slash ]
|
||||
* require_once( $vendor_path . '/otgs/ui/loader.php' );
|
||||
* otgs_ui_initialize( $vendor_path . '/otgs/ui', $vendor_url . '/otgs/ui' );
|
||||
*
|
||||
* =================
|
||||
* Restrictions
|
||||
* =================
|
||||
* - Assets are registered at init:1: doing it earlier will cause problems with core assets registered at init:0
|
||||
* - Their handles are stored in constants that you can use as dependencies, on assets registered after init:-100.
|
||||
*
|
||||
* @package otgs/ui
|
||||
*/
|
||||
|
||||
/**
|
||||
* OTGS UI version - increase after every major update.
|
||||
*/
|
||||
$otg_ui_version = 111;
|
||||
|
||||
/**
|
||||
* =================
|
||||
* || WARNING ||
|
||||
* =================
|
||||
*
|
||||
* DO NOT EDIT below this line.
|
||||
*/
|
||||
|
||||
global $otg_ui_versions;
|
||||
|
||||
if ( ! isset( $otg_ui_versions ) ) {
|
||||
$otg_ui_versions = array();
|
||||
}
|
||||
|
||||
if ( ! isset( $otg_ui_versions[ $otg_ui_version ] ) ) {
|
||||
// Initialize the path to this version.
|
||||
$otg_ui_versions[ $otg_ui_version ] = array(
|
||||
'path' => wp_normalize_path( dirname( __FILE__ ) ),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ( ! function_exists( 'otgs_ui_initialize' ) ) {
|
||||
|
||||
/**
|
||||
* @param string $vendor_path Path to the root of your relative vendor directory housing this repository (no trailing slash).
|
||||
* @param string $vendor_url URL of the root of your relative vendor directory housing this repository, no trailing slash.
|
||||
*/
|
||||
function otgs_ui_initialize( $vendor_path, $vendor_url ) {
|
||||
global $otg_ui_versions;
|
||||
|
||||
// Make sure we compare with the canonical path.
|
||||
if ( is_link( $vendor_path ) ) {
|
||||
$vendor_path = readlink( $vendor_path );
|
||||
}
|
||||
|
||||
$vendor_path = wp_normalize_path( $vendor_path );
|
||||
$vendor_path = untrailingslashit( $vendor_path );
|
||||
$vendor_url = untrailingslashit( $vendor_url );
|
||||
|
||||
// Save the url in the version with a matching path.
|
||||
foreach ( $otg_ui_versions as $version => $data ) {
|
||||
if ( $otg_ui_versions[ $version ]['path'] === $vendor_path ) {
|
||||
$otg_ui_versions[ $version ]['url'] = $vendor_url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'otgs_ui_plugins_loaded' ) ) {
|
||||
/**
|
||||
* Function hooked to the `plugins_loaded` action as early as possible.
|
||||
*/
|
||||
function otgs_ui_plugins_loaded() {
|
||||
global $otg_ui_versions;
|
||||
|
||||
// Find the latest version.
|
||||
$latest = 0;
|
||||
foreach ( $otg_ui_versions as $version => $data ) {
|
||||
if ( $version > $latest ) {
|
||||
$latest = $version;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $latest > 0 && isset( $otg_ui_versions[ $latest ]['url'] ) ) {
|
||||
// Require all the available classes: we need to overcome autoloaders!!
|
||||
require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_Assets_Handles.php';
|
||||
require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_Assets_Store.php';
|
||||
require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_UI_Assets.php';
|
||||
require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_UI_Loader.php';
|
||||
|
||||
// Initialize the assets loader with its assets and store dependencies.
|
||||
$assets_store = new OTGS_Assets_Store();
|
||||
$assets = new OTGS_UI_Assets( $otg_ui_versions[ $latest ]['url'] . '/dist', $assets_store );
|
||||
$loader = new OTGS_UI_Loader( $assets_store, $assets );
|
||||
$loader->load();
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'plugins_loaded', 'otgs_ui_plugins_loaded', -PHP_INT_MAX );
|
||||
}
|
||||
42
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/js/otgsPopoverTooltip.js
vendored
Normal file
42
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/js/otgsPopoverTooltip.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import tippy from 'tippy.js';
|
||||
import '../scss/otgsPopoverTooltip.scss';
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
initialize();
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Element} element
|
||||
*/
|
||||
export function initSingle(element) {
|
||||
/**
|
||||
* @see https://atomiks.github.io/tippyjs/#all-options
|
||||
* @type {{arrow: boolean, theme: string, animation: string, sticky: boolean, interactive: boolean}}
|
||||
*/
|
||||
const args = {
|
||||
arrow: true,
|
||||
theme: 'otgs',
|
||||
animation: 'fade',
|
||||
sticky: true,
|
||||
interactive: true,
|
||||
};
|
||||
if ( !element.getAttribute('data-tippy-content') && element.getAttribute('title') ) {
|
||||
args.content = element.getAttribute('title');
|
||||
element.removeAttribute('title');
|
||||
}
|
||||
tippy(element, args);
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
/**
|
||||
* @param {NodeList} elements
|
||||
*/
|
||||
//TODO change all .wpml-popover to otgs-popover
|
||||
const elements = [...document.querySelectorAll('.js-otgs-popover-tooltip, .js-wpml-popover-tooltip')];
|
||||
|
||||
/**
|
||||
* @param {Element} element
|
||||
*/
|
||||
elements.forEach(element => initSingle(element));
|
||||
}
|
||||
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/js/otgsSwitcher.js
vendored
Normal file
1
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/js/otgsSwitcher.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import '../scss/otgsSwitcher.scss';
|
||||
23
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/js/otgsTableStickyHeader.js
vendored
Normal file
23
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/js/otgsTableStickyHeader.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*global jQuery*/
|
||||
|
||||
import stickyTableHeaders from 'sticky-table-headers';
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
/**
|
||||
* @param {NodeList} elementS
|
||||
*/
|
||||
const elements = [...document.querySelectorAll('.js-otgs-table-sticky-header')];
|
||||
const args = {
|
||||
fixedOffset: jQuery('#wpadminbar')
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Element} element
|
||||
*/
|
||||
elements.forEach(element => {
|
||||
jQuery(element).stickyTableHeaders(args).on('enabledStickiness.stickyTableHeaders', () => {
|
||||
element.getElementsByClassName('tableFloatingHeaderOriginal')[0].style.background = 'rgba(255,255,255,.8)';
|
||||
});
|
||||
});
|
||||
});
|
||||
10
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_Assets_Handles.php
vendored
Normal file
10
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_Assets_Handles.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class OTGS_Assets_Handles {
|
||||
const POPOVER_TOOLTIP = 'otgsPopoverTooltip';
|
||||
const SWITCHER = 'otgsSwitcher';
|
||||
const TABLE_STICKY_HEADER = 'otgsTableStickyHeader';
|
||||
}
|
||||
95
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_Assets_Store.php
vendored
Normal file
95
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_Assets_Store.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class OTGS_Assets_Store {
|
||||
|
||||
/** @var array */
|
||||
private $assets_files_store = array();
|
||||
/** @var array */
|
||||
private $assets = array();
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param null $handle
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function get( $type, $handle = null ) {
|
||||
$result = array();
|
||||
|
||||
$this->parse_assets();
|
||||
|
||||
if ( array_key_exists( $type, $this->assets ) ) {
|
||||
$result = $this->assets[ $type ];
|
||||
|
||||
if ( $handle ) {
|
||||
if ( array_key_exists( $handle, $this->assets[ $type ] ) ) {
|
||||
$result = $this->assets[ $type ][ $handle ];
|
||||
} else {
|
||||
$result = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function add_assets_location( $path ) {
|
||||
if ( ! in_array( $path, $this->assets, true ) ) {
|
||||
$this->assets_files_store[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses $this->assets
|
||||
*/
|
||||
private function parse_assets() {
|
||||
if ( ! $this->assets ) {
|
||||
foreach ( $this->assets_files_store as $assets_file ) {
|
||||
$this->add_asset( $assets_file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $assets_file
|
||||
*/
|
||||
private function add_asset( $assets_file ) {
|
||||
if ( ! is_file( $assets_file ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$assets = file_get_contents( $assets_file );
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ( ! $assets || ! is_string( $assets ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$assets_data = json_decode( $assets, true );
|
||||
|
||||
if ( $assets_data && array_key_exists( 'entrypoints', $assets_data ) ) {
|
||||
foreach ( $assets_data['entrypoints'] as $handle => $resources ) {
|
||||
$this->add_resources( $handle, $resources );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $handle
|
||||
* @param array $resources
|
||||
*/
|
||||
private function add_resources( $handle, $resources ) {
|
||||
foreach ( $resources as $type => $path ) {
|
||||
if ( ! array_key_exists( $type, $this->assets ) ) {
|
||||
$this->assets[ $type ] = array();
|
||||
}
|
||||
$this->assets[ $type ][ $handle ] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_UI_Assets.php
vendored
Normal file
101
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_UI_Assets.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class OTGS_UI_Assets {
|
||||
const ASSETS_TYPES_SCRIPT = 'script';
|
||||
const ASSETS_TYPES_STYLE = 'style';
|
||||
|
||||
/** @var string */
|
||||
private $assets_root_url;
|
||||
|
||||
/** @var OTGS_Assets_Store */
|
||||
private $assets_store;
|
||||
|
||||
/**
|
||||
* OTGS_UI_Assets constructor.
|
||||
*
|
||||
* @param string $assets_root_url Root URL for the dist directory on this vendor library.
|
||||
* @param \OTGS_Assets_Store $assets_store
|
||||
*/
|
||||
public function __construct( $assets_root_url, OTGS_Assets_Store $assets_store ) {
|
||||
$this->assets_store = $assets_store;
|
||||
$this->assets_root_url = $assets_root_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers both scripts and styles
|
||||
*/
|
||||
public function register() {
|
||||
$this->register_scripts();
|
||||
$this->register_styles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers scripts
|
||||
*/
|
||||
private function register_scripts() {
|
||||
foreach ( $this->assets_store->get( 'js' ) as $handle => $path ) {
|
||||
$this->register_script( $handle, $path );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $handle
|
||||
* @param string $path
|
||||
*/
|
||||
private function register_script( $handle, $path ) {
|
||||
$this->register_resource( self::ASSETS_TYPES_SCRIPT, $handle, $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $handle
|
||||
* @param array $path
|
||||
*/
|
||||
private function register_resource( $type, $handle, $path ) {
|
||||
$function = null;
|
||||
if ( self::ASSETS_TYPES_SCRIPT === $type ) {
|
||||
$function = 'wp_register_script';
|
||||
}
|
||||
if ( self::ASSETS_TYPES_STYLE === $type ) {
|
||||
$function = 'wp_register_style';
|
||||
}
|
||||
if ( ! $function ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 1 === count( $path ) ) {
|
||||
$function( $handle, $this->get_assets_base_url() . '/' . $path[0] );
|
||||
} else {
|
||||
foreach ( $path as $index => $resource ) {
|
||||
$function( $handle . '-' . ( $index + 1 ), $this->get_assets_base_url() . '/' . $resource );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function get_assets_base_url() {
|
||||
return rtrim( $this->assets_root_url, '/\\' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers styles
|
||||
*/
|
||||
private function register_styles() {
|
||||
foreach ( $this->assets_store->get( 'css' ) as $handle => $path ) {
|
||||
$this->register_style( $handle, $path );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $handle
|
||||
* @param string $path
|
||||
*/
|
||||
private function register_style( $handle, $path ) {
|
||||
$this->register_resource( self::ASSETS_TYPES_STYLE, $handle, $path );
|
||||
}
|
||||
}
|
||||
45
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_UI_Loader.php
vendored
Normal file
45
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/src/php/OTGS_UI_Loader.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class OTGS_UI_Loader {
|
||||
|
||||
/** @var \OTGS_UI_Assets */
|
||||
private $assets;
|
||||
|
||||
/** @var \OTGS_Assets_Store */
|
||||
private $store;
|
||||
|
||||
/**
|
||||
* OTGS_UI_Loader constructor.
|
||||
*
|
||||
* @param \OTGS_Assets_Store $locator
|
||||
* @param \OTGS_UI_Assets $assets
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct( OTGS_Assets_Store $locator = null, OTGS_UI_Assets $assets = null ) {
|
||||
if ( ! $locator || ! $assets ) {
|
||||
throw new InvalidArgumentException( 'Missing assets and assets store' );
|
||||
}
|
||||
|
||||
$this->store = $locator;
|
||||
$this->assets = $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks to the registration of all assets to the `ìnit` action
|
||||
*/
|
||||
public function load() {
|
||||
add_action( 'init', array( $this, 'register' ), 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the assets and registers them
|
||||
*/
|
||||
public function register() {
|
||||
$this->store->add_assets_location( dirname( __FILE__ ) . '/../../dist/assets.json' );
|
||||
$this->assets->register();
|
||||
}
|
||||
}
|
||||
104
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/webpack.config.js
vendored
Normal file
104
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/ui/webpack.config.js
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
const path = require('path');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const WebpackAssetsManifest = require('webpack-assets-manifest');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
|
||||
/**
|
||||
* @typedef LibrariesHash
|
||||
* @property {object} [entryChunkName: string] A unique entry ID
|
||||
* @property {array} entryChunkName.entry - A list of entries to bundle with the library
|
||||
* @property {string} [entryChunkName.filename] - The target file name (if omitted, the entry entryChunkName will be used
|
||||
* @property {string} [entryChunkName.var] - The name of the global variable to which the library will be assigned
|
||||
*
|
||||
* @type LibrariesHash
|
||||
*/
|
||||
const libraries = {
|
||||
'otgsSwitcher': {
|
||||
entry: ['./src/js/otgsSwitcher.js'],
|
||||
},
|
||||
'otgsPopoverTooltip': {
|
||||
entry: ['./src/js/otgsPopoverTooltip.js'],
|
||||
},
|
||||
'otgsTableStickyHeader': {
|
||||
entry: ['./src/js/otgsTableStickyHeader.js'],
|
||||
},
|
||||
};
|
||||
|
||||
const getEntries = () => {
|
||||
const entries = {};
|
||||
Object.keys(libraries).map(key => entries[key] = libraries[key].entry);
|
||||
|
||||
return entries;
|
||||
};
|
||||
|
||||
const getEntryFileName = (chunk) => {
|
||||
if (libraries.hasOwnProperty(chunk.id) && libraries[chunk.id].hasOwnProperty('filename') && libraries[chunk.id].filename) {
|
||||
return libraries[chunk.id].filename;
|
||||
}
|
||||
return path.join(chunk.name);
|
||||
};
|
||||
|
||||
module.exports = env => {
|
||||
const isProduction = env === 'production';
|
||||
|
||||
console.log('getEntries()', getEntries());
|
||||
// console.log('getVars()',getVars());
|
||||
|
||||
return {
|
||||
entry: getEntries,
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist'),
|
||||
filename: chunkData => path.join('js', getEntryFileName(chunkData.chunk) + '.js?ver=' + chunkData.chunk.hash),
|
||||
chunkFilename: '[id].[name].js?ver=[chunkhash]',
|
||||
library: ["OTGSUI", "[name]"],
|
||||
libraryTarget: 'var'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
query: {
|
||||
presets: ['es2015'],
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: [
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
sourceMap: !isProduction,
|
||||
minimize: isProduction,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: !isProduction,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(['dist']),
|
||||
new ExtractTextPlugin({
|
||||
filename: path.join('css', '[name].css?ver=[chunkhash]'),
|
||||
}),
|
||||
new WebpackAssetsManifest({
|
||||
output: path.join(__dirname, 'dist', 'assets.json'),
|
||||
entrypoints: true,
|
||||
}),
|
||||
],
|
||||
devtool: isProduction ? '' : 'inline-source-map'
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user