This commit is contained in:
KhaiNguyen
2020-02-13 10:39:37 +07:00
commit 59401cb805
12867 changed files with 4646216 additions and 0 deletions

View File

@@ -0,0 +1,360 @@
/* Overriding WordPress native styles */
.ocdi {
max-width: none;
}
.ocdi h2 {
text-align: inherit;
}
.ocdi h2:first-child,
.ocdi h3:first-child {
margin-top: 0;
}
.ocdi hr {
margin: 2.62em 0;
}
.feature-section + hr {
margin-top: 0;
}
#wpbody select {
height: auto;
padding: .62em;
line-height: inherit;
}
.ocdi .notice {
display: block !important;
}
/* Plugin elements */
.ocdi__demo-import-files {
width: 100%;
}
.ocdi__demo-import-preview-image-message {
font-style: italic;
}
/* Plugin title */
.ocdi__title:before {
width: auto;
height: auto;
font-size: inherit;
}
/* Plugin intro text */
.ocdi__intro-text ul {
padding: 0 4%;
list-style-type: square;
}
/* Plugin multi select import and Plugin file upload containers */
.ocdi__file-upload,
.ocdi__multi-select-import,
.ocdi__demo-import-notice:not(:empty) {
padding: 4%;
margin: 1.62em 0;
background-color: #ffffff;
border: 1px solid #e5e5e5;
}
.ocdi__file-upload {
margin: 0;
margin-bottom: -1px;
}
.ocdi__file-upload span {
font-size: .81em;
font-weight: normal;
opacity: .66;
}
.ocdi__demo-import-notice:not(:empty) {
border: 0;
border-left: 4px solid #00a0d2;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
}
[dir="rtl"] .ocdi__demo-import-notice:not(:empty) {
border: 0;
border-right: 4px solid #00a0d2;
}
/* Plugin button */
.ocdi__button-container {
margin-top: 1.62em;
}
/* AJAX loader */
p.ocdi__ajax-loader {
font-size: 1.5em;
display: none;
}
.ocdi__ajax-loader .spinner {
display: inline-block;
float: none;
visibility: visible;
margin-bottom: 6px;
}
/* New grid layout */
.ocdi__gl-navigation li a {
-webkit-box-shadow: none;
box-shadow: none;
}
.ocdi__gl-item {
float: left;
width: 100%;
margin: 0 0 20px 0;
position: relative;
border: 1px solid #ddd;
-webkit-box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.ocdi__gl-item-image-container {
display: block;
overflow: hidden;
position: relative;
-webkit-backface-visibility: hidden;
-webkit-transition: opacity 0.2s ease-in-out;
transition: opacity 0.2s ease-in-out;
}
.ocdi__gl-item-image-container::after {
content: "";
display: block;
padding-top: 60%;
}
.ocdi__gl-item-image {
height: auto;
position: absolute;
left: 0;
top: 0;
width: 100%;
-webkit-transition: opacity 0.2s ease-in-out;
transition: opacity 0.2s ease-in-out;
}
.ocdi__gl-item-image--no-image {
display: inline-block;
width: 50%;
text-align: center;
position: absolute;
top: 45%;
right: 25%;
left: 25%;
}
.ocdi__gl-item-footer {
height: 30px;
margin: 0;
padding: 10px;
-webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
background: #ffffff;
background: rgba(255,255,255,0.65);
}
h4.ocdi__gl-item-title {
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: inline-block;
margin: 6px 0 0 0;
}
.ocdi__gl-item-footer--with-preview h4.ocdi__gl-item-title {
width: calc(100% - 140px);
}
.ocdi__gl-item-button {
float: right;
}
.ocdi__gl-item-button + .ocdi__gl-item-button {
margin-right: 5px;
}
@media (max-width: 782px) {
h4.ocdi__gl-item-title,
.ocdi__gl-item-footer--with-preview h4.ocdi__gl-item-title {
width: 100%;
margin-bottom: 10px;
}
.ocdi__gl-item-button {
width: calc(50% - 10px);
margin-bottom: 10px;
}
.ocdi__gl-item-button + .ocdi__gl-item-button {
float: left;
}
.ocdi__gl-item-footer {
height: 72px;
}
}
.ocdi__gl-header {
display: inline-block;
width: calc(100% - 40px);
background-color: #ffffff;
margin-bottom: 20px;
padding: 0 20px;
}
.ocdi__gl-navigation {
font-size: 13px;
width: 100%;
float: left;
}
.ocdi__gl-navigation ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
.ocdi__gl-navigation li {
float: left;
margin: 0 15px;
}
.ocdi__gl-navigation li.active a,
.ocdi__gl-navigation li.active a:hover {
border-bottom: 4px solid #666666;
}
.ocdi__gl-navigation li a {
display: block;
text-align: center;
text-decoration: none;
color: #444444;
border-bottom: 4px solid #ffffff;
padding: 15px 0;
}
.ocdi__gl-navigation li a:hover {
color: #00a0d2;
border-bottom: 4px solid #ffffff;
cursor:pointer;
}
.ocdi__gl-search-input {
width: 100%;
margin: 10px 0;
}
@media (min-width: 640px) {
.ocdi__gl-navigation {
width: calc(100% - 180px);
}
.ocdi__gl-navigation li {
margin: 0;
}
.ocdi__gl-navigation li a {
padding: 15px;
}
.ocdi__gl-search-input {
display: inline-block;
width: 180px;
height: 30px;
margin: 0;
margin-top: 11px;
}
.ocdi__gl-item-container {
margin-right: -20px;
}
.ocdi__gl-item {
width: calc(50% - 20px);
margin: 0 20px 20px 0;
}
}
@media (min-width: 1120px) {
.ocdi__gl-item-container {
margin-right: -30px;
}
.ocdi__gl-item {
width: calc(33.333% - 30px);
margin: 0 30px 30px 0;
}
}
/* Grid animations */
@keyframes ocdi-fade {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.ocdi-is-fadeout {
animation: ocdi-fade linear 200ms 1 forwards;
}
.ocdi-is-fadein {
animation: ocdi-fade linear 200ms 1 reverse forwards;
}
/* Grid layout modal window */
.ocdi__modal-image-container {
width: 100%;
height: 180px;
margin: 0;
overflow: hidden;
}
.ocdi__modal-item-title {
margin-top: 0.5em;
font-weight: bold;
}
.ocdi__modal-image-container img {
width: 100%;
}
.ocdi__modal-notice.ocdi__demo-import-notice:not(:empty) {
border: 1px solid #e5e5e5;
border-left: 4px solid #00a0d2;
margin: 1em 0 0;
}
/* Redux */
.ocdi__redux-option-name-label {
margin-right: 5px;
}

View File

@@ -0,0 +1,329 @@
jQuery( function ( $ ) {
'use strict';
/**
* ---------------------------------------
* ------------- Events ------------------
* ---------------------------------------
*/
/**
* No or Single predefined demo import button click.
*/
$( '.js-ocdi-import-data' ).on( 'click', function () {
// Reset response div content.
$( '.js-ocdi-ajax-response' ).empty();
// Prepare data for the AJAX call
var data = new FormData();
data.append( 'action', 'ocdi_import_demo_data' );
data.append( 'security', ocdi.ajax_nonce );
data.append( 'selected', $( '#ocdi__demo-import-files' ).val() );
if ( $('#ocdi__content-file-upload').length ) {
data.append( 'content_file', $('#ocdi__content-file-upload')[0].files[0] );
}
if ( $('#ocdi__widget-file-upload').length ) {
data.append( 'widget_file', $('#ocdi__widget-file-upload')[0].files[0] );
}
if ( $('#ocdi__customizer-file-upload').length ) {
data.append( 'customizer_file', $('#ocdi__customizer-file-upload')[0].files[0] );
}
if ( $('#ocdi__redux-file-upload').length ) {
data.append( 'redux_file', $('#ocdi__redux-file-upload')[0].files[0] );
data.append( 'redux_option_name', $('#ocdi__redux-option-name').val() );
}
// AJAX call to import everything (content, widgets, before/after setup)
ajaxCall( data );
});
/**
* Grid Layout import button click.
*/
$( '.js-ocdi-gl-import-data' ).on( 'click', function () {
var selectedImportID = $( this ).val();
var $itemContainer = $( this ).closest( '.js-ocdi-gl-item' );
// If the import confirmation is enabled, then do that, else import straight away.
if ( ocdi.import_popup ) {
displayConfirmationPopup( selectedImportID, $itemContainer );
}
else {
gridLayoutImport( selectedImportID, $itemContainer );
}
});
/**
* Grid Layout categories navigation.
*/
(function () {
// Cache selector to all items
var $items = $( '.js-ocdi-gl-item-container' ).find( '.js-ocdi-gl-item' ),
fadeoutClass = 'ocdi-is-fadeout',
fadeinClass = 'ocdi-is-fadein',
animationDuration = 200;
// Hide all items.
var fadeOut = function () {
var dfd = jQuery.Deferred();
$items
.addClass( fadeoutClass );
setTimeout( function() {
$items
.removeClass( fadeoutClass )
.hide();
dfd.resolve();
}, animationDuration );
return dfd.promise();
};
var fadeIn = function ( category, dfd ) {
var filter = category ? '[data-categories*="' + category + '"]' : 'div';
if ( 'all' === category ) {
filter = 'div';
}
$items
.filter( filter )
.show()
.addClass( 'ocdi-is-fadein' );
setTimeout( function() {
$items
.removeClass( fadeinClass );
dfd.resolve();
}, animationDuration );
};
var animate = function ( category ) {
var dfd = jQuery.Deferred();
var promise = fadeOut();
promise.done( function () {
fadeIn( category, dfd );
} );
return dfd;
};
$( '.js-ocdi-nav-link' ).on( 'click', function( event ) {
event.preventDefault();
// Remove 'active' class from the previous nav list items.
$( this ).parent().siblings().removeClass( 'active' );
// Add the 'active' class to this nav list item.
$( this ).parent().addClass( 'active' );
var category = this.hash.slice(1);
// show/hide the right items, based on category selected
var $container = $( '.js-ocdi-gl-item-container' );
$container.css( 'min-width', $container.outerHeight() );
var promise = animate( category );
promise.done( function () {
$container.removeAttr( 'style' );
} );
} );
}());
/**
* Grid Layout search functionality.
*/
$( '.js-ocdi-gl-search' ).on( 'keyup', function( event ) {
if ( 0 < $(this).val().length ) {
// Hide all items.
$( '.js-ocdi-gl-item-container' ).find( '.js-ocdi-gl-item' ).hide();
// Show just the ones that have a match on the import name.
$( '.js-ocdi-gl-item-container' ).find( '.js-ocdi-gl-item[data-name*="' + $(this).val().toLowerCase() + '"]' ).show();
}
else {
$( '.js-ocdi-gl-item-container' ).find( '.js-ocdi-gl-item' ).show();
}
} );
/**
* ---------------------------------------
* --------Helper functions --------------
* ---------------------------------------
*/
/**
* Prepare grid layout import data and execute the AJAX call.
*
* @param int selectedImportID The selected import ID.
* @param obj $itemContainer The jQuery selected item container object.
*/
function gridLayoutImport( selectedImportID, $itemContainer ) {
// Reset response div content.
$( '.js-ocdi-ajax-response' ).empty();
// Hide all other import items.
$itemContainer.siblings( '.js-ocdi-gl-item' ).fadeOut( 500 );
$itemContainer.animate({
opacity: 0
}, 500, 'swing', function () {
$itemContainer.animate({
opacity: 1
}, 500 )
});
// Hide the header with category navigation and search box.
$itemContainer.closest( '.js-ocdi-gl' ).find( '.js-ocdi-gl-header' ).fadeOut( 500 );
// Append a title for the selected demo import.
$itemContainer.parent().prepend( '<h3>' + ocdi.texts.selected_import_title + '</h3>' );
// Remove the import button of the selected item.
$itemContainer.find( '.js-ocdi-gl-import-data' ).remove();
// Prepare data for the AJAX call
var data = new FormData();
data.append( 'action', 'ocdi_import_demo_data' );
data.append( 'security', ocdi.ajax_nonce );
data.append( 'selected', selectedImportID );
// AJAX call to import everything (content, widgets, before/after setup)
ajaxCall( data );
}
/**
* Display the confirmation popup.
*
* @param int selectedImportID The selected import ID.
* @param obj $itemContainer The jQuery selected item container object.
*/
function displayConfirmationPopup( selectedImportID, $itemContainer ) {
var $dialogContiner = $( '#js-ocdi-modal-content' );
var currentFilePreviewImage = ocdi.import_files[ selectedImportID ]['import_preview_image_url'] || ocdi.theme_screenshot;
var previewImageContent = '';
var importNotice = ocdi.import_files[ selectedImportID ]['import_notice'] || '';
var importNoticeContent = '';
var dialogOptions = $.extend(
{
'dialogClass': 'wp-dialog',
'resizable': false,
'width': '632',
'height': 'auto',
'modal': true
},
ocdi.dialog_options,
{
'buttons':
[
{
text: ocdi.texts.dialog_no,
class: 'kdadmin-button',
click: function() {
$(this).dialog('close');
}
},
{
text: ocdi.texts.dialog_yes,
class: 'kdadmin-button',
click: function() {
$(this).dialog('close');
gridLayoutImport( selectedImportID, $itemContainer );
}
}
]
});
if ( '' === currentFilePreviewImage ) {
previewImageContent = '<p>' + ocdi.texts.missing_preview_image + '</p>';
}
else {
previewImageContent = '<div class="ocdi__modal-image-container"><img src="' + currentFilePreviewImage + '" alt="' + ocdi.import_files[ selectedImportID ]['import_file_name'] + '"></div>'
}
// Prepare notice output.
if( '' !== importNotice ) {
importNoticeContent = '<div class="ocdi__modal-notice ocdi__demo-import-notice">' + importNotice + '</div>';
}
// Populate the dialog content.
$dialogContiner.prop( 'title', ocdi.texts.dialog_title );
$dialogContiner.html(
'<p class="ocdi__modal-item-title">' + ocdi.import_files[ selectedImportID ]['import_file_name'] + '</p>' +
previewImageContent +
importNoticeContent
);
// Display the confirmation popup.
$dialogContiner.dialog( dialogOptions );
}
/**
* The main AJAX call, which executes the import process.
*
* @param FormData data The data to be passed to the AJAX call.
*/
function ajaxCall( data ) {
$.ajax({
method: 'POST',
url: ocdi.ajax_url,
data: data,
contentType: false,
processData: false,
beforeSend: function() {
$( '.js-ocdi-ajax-loader' ).show();
}
})
.done( function( response ) {
if ( 'undefined' !== typeof response.status && 'newAJAX' === response.status ) {
ajaxCall( data );
}
else if ( 'undefined' !== typeof response.status && 'customizerAJAX' === response.status ) {
// Fix for data.set and data.delete, which they are not supported in some browsers.
var newData = new FormData();
newData.append( 'action', 'ocdi_import_customizer_data' );
newData.append( 'security', ocdi.ajax_nonce );
// Set the wp_customize=on only if the plugin filter is set to true.
if ( true === ocdi.wp_customize_on ) {
newData.append( 'wp_customize', 'on' );
}
ajaxCall( newData );
}
else if ( 'undefined' !== typeof response.status && 'afterAllImportAJAX' === response.status ) {
// Fix for data.set and data.delete, which they are not supported in some browsers.
var newData = new FormData();
newData.append( 'action', 'ocdi_after_import_data' );
newData.append( 'security', ocdi.ajax_nonce );
ajaxCall( newData );
}
else if ( 'undefined' !== typeof response.message ) {
$( '.js-ocdi-ajax-response' ).append( '<p>' + response.message + '</p>' );
$( '.js-ocdi-ajax-loader' ).hide();
// Trigger custom event, when OCDI import is complete.
$( document ).trigger( 'ocdiImportComplete' );
}
else {
$( '.js-ocdi-ajax-response' ).append( '<div class="notice notice-error is-dismissible"><p>' + response + '</p></div>' );
$( '.js-ocdi-ajax-loader' ).hide();
}
})
.fail( function( error ) {
$( '.js-ocdi-ajax-response' ).append( '<div class="notice notice-error is-dismissible"><p>Error: ' + error.statusText + ' (' + error.status + ')' + '</p></div>' );
$( '.js-ocdi-ajax-loader' ).hide();
});
}
} );