first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
*.log
node_modules
.sass-cache
.idea
package-lock.json

View File

@@ -0,0 +1,158 @@
# Jet Menu
JetMenu is a plugin that assists you in creating and styling up mega menu. Youll be able to create content for the menu items and customize items appearance, add menu badges and icons, change menu item background - all this with JetMenu plugin, which is easy-to-use and has intuitive and clear interface.
With JetMenu you can style menu items using different fonts and all colors of the world. There are multiple settings to set the menu item shadows, customization options for Active and Hover mode, etc.
The plugin works in tandem with Elementor live page builder, allowing to add content to menu items in a drag-and-drop way. The content and style settings share the same treats with Elementor and JetElements. Youll also get Custom Menu module for Elementor, which allows you to add your menu to any page layout section you want.
# ChangeLog
## 1.5.14 - 18.07.2019
* Fixed: minor js issues
## 1.5.13 - 15.07.2019
* Added: need helps links to widgets
* Fixed: minor CSS issue
## 1.5.12 - 08.07.2019
* Updated: sub items open trigger
## 1.5.11 - 13.05.2019
* Added: more compatibility with third-party plugins
## 1.5.10 - 03.05.2019
* Fixed: border-radius for last menu item
## 1.5.9 - 24.04.2019
* Added: `stretch` option to `Menu items alignment` control
* Added: better RTL compatibility
## 1.5.8.1
* Fixed: mega menu width in mobile mode
## 1.5.8
* Fixed: mega menu width
## 1.5.7
* Added: better compatibility on tablet devices
## 1.5.6
* Added: custom mega menu settings in the Menu Item Settings Popup
## 1.5.5
* UPD: cherry-framework v1.5.11
* FIX: scroll in mobile menu
## 1.5.4
* ADD: RU localization
* ADD: integration with Epic News Elements plugin
## 1.5.3
* ADD: option `Vertical mega menu position` relative menu item or menu container
* ADD: minor bug fixes
## 1.5.2
* ADD: style controls for `Active State` menu item in the Vertical Mega Menu Widget
* ADD: compatibility with Phlox and Phlox Pro themes
## 1.5.1
* ADD: closing the mobile menu when clicking outside the mobile menu area
* FIX: prevent displaying submenu outside the window
* FIX: prevent duplicate sub-menu and mega-menu when the section is sticky
* FIX: applying cached css on https sites
* FIX: minor CSS fixes
## 1.5.0
* ADD: allow to cache menu CSS
* FIX: minor CSS fixes
## 1.4.4
* ADD: compatibility with Header Footer Elementor plugin
* UPD: cherry-framework v1.5.10
## 1.4.3
* ADD: multiple improvements and bug fixes
## 1.4.2
* FIX: showing sub-menu and sub-mega-menu when loading a page
## 1.4.1
* ADD: Mobile breakpoint option
* ADD: multiple performance improvements and bug fixes
## 1.4.0
* ADD: the ability to display mega-menu content in the Custom Menu Widget
* UPD: changed Custom Menu Widget name to Vertical Mega Menu
* ADD: style controls for the Mega Menu Widget
* ADD: Show Submenu Item Description option
* ADD: multiple performance improvements and bug fixes
## 1.3.6
* ADD: Mobile layout close panel event
## 1.3.5
* ADD: Sub items open event option
* UPD: Better Avada compatibility
## 1.3.4
* UPD: better Astra compatibility
* FIX: prevent error with 3-rd party optimization plugins
* FIX: Polylang compatibility
## 1.3.3
* UPD: better compatibility with Betheme
* FIX: Elementor 2.0.0 + JetElements compatibility
* FIX: plugin updater
## 1.3.1.1
* Updated: Minified main front-end CSS
* Fixed: Prevent custom user classes from adding 'jet-' prefixes
## 1.3.1
* Updated: Elementor content processing inside mega menu items
## 1.3.0.3
* Fixed: Custom selector mega container mobile width
## 1.3.0.1
* Updated main content min-width default value;
## 1.3.0
* Added main content min-width css style option;
* Added presets functionality;
## 1.2.0
* Added Mega Menu module;
* Added minor bug fixes.
## 1.1.1
* Added compatibility with the most popular WordPress themes:
1. Avada;
2. BeTheme;
3. Enfold;
4. OceanWP;
5. Zerif;
6. Hestia;
7. GeneratePress;
8. Astra;
9. Storefront.
* Added compatibility with The Events Calendar plugin;
* Added minor bug fixes.
## 1.1.0
* Added Export/Import options;
* Added Dummy Data files.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.elementor-panel .elementor-header-button .elementor-icon.eicon-menu-bar{font-size:20px}.elementor-panel .elementor-header-button .elementor-icon.eicon-menu-bar:before{content:'\E87E'}.elementor-panel #elementor-panel-footer-exit .fa-times:before{content:'\f053'}.elementor-panel #elementor-panel-footer-exit .eicon-close:before{content:'\E87E'}.elementor-panel #elementor-panel-footer-settings .fa-cog:before{content:'\f053'}.elementor-panel #elementor-panel-footer-settings .eicon-cog:before{content:'\E87E'}.elementor-panel #elementor-panel-saver-menu-save-draft,.elementor-panel #elementor-panel-saver-menu-discard{display:none !important}

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,659 @@
/**
* ResizeSensor.js
*/
!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.ResizeSensor=t()}("undefined"!=typeof window?window:this,function(){function e(e,t){var i=Object.prototype.toString.call(e),n="[object Array]"===i||"[object NodeList]"===i||"[object HTMLCollection]"===i||"[object Object]"===i||"undefined"!=typeof jQuery&&e instanceof jQuery||"undefined"!=typeof Elements&&e instanceof Elements,o=0,s=e.length;if(n)for(;o<s;o++)t(e[o]);else t(e)}if("undefined"==typeof window)return null;var t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return window.setTimeout(e,20)},i=function(n,o){function s(){var e=[];this.add=function(t){e.push(t)};var t,i;this.call=function(){for(t=0,i=e.length;t<i;t++)e[t].call()},this.remove=function(n){var o=[];for(t=0,i=e.length;t<i;t++)e[t]!==n&&o.push(e[t]);e=o},this.length=function(){return e.length}}function r(e,i){if(e)if(e.resizedAttached)e.resizedAttached.add(i);else{e.resizedAttached=new s,e.resizedAttached.add(i),e.resizeSensor=document.createElement("div"),e.resizeSensor.className="resize-sensor";var n="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;",o="position: absolute; left: 0; top: 0; transition: 0s;";e.resizeSensor.style.cssText=n,e.resizeSensor.innerHTML='<div class="resize-sensor-expand" style="'+n+'"><div style="'+o+'"></div></div><div class="resize-sensor-shrink" style="'+n+'"><div style="'+o+' width: 200%; height: 200%"></div></div>',e.appendChild(e.resizeSensor),e.resizeSensor.offsetParent!==e&&(e.style.position="relative");var r,d,c,l,f=e.resizeSensor.childNodes[0],a=f.childNodes[0],h=e.resizeSensor.childNodes[1],u=e.offsetWidth,z=e.offsetHeight,v=function(){a.style.width="100000px",a.style.height="100000px",f.scrollLeft=1e5,f.scrollTop=1e5,h.scrollLeft=1e5,h.scrollTop=1e5};v();var p=function(){d=0,r&&(u=c,z=l,e.resizedAttached&&e.resizedAttached.call())},y=function(){c=e.offsetWidth,l=e.offsetHeight,(r=c!=u||l!=z)&&!d&&(d=t(p)),v()},m=function(e,t,i){e.attachEvent?e.attachEvent("on"+t,i):e.addEventListener(t,i)};m(f,"scroll",y),m(h,"scroll",y)}}e(n,function(e){r(e,o)}),this.detach=function(e){i.detach(n,e)}};return i.detach=function(t,i){e(t,function(e){e&&(e.resizedAttached&&"function"==typeof i&&(e.resizedAttached.remove(i),e.resizedAttached.length())||e.resizeSensor&&(e.contains(e.resizeSensor)&&e.removeChild(e.resizeSensor),delete e.resizeSensor,delete e.resizedAttached))})},i});
( function( $, settings ) {
'use strict';
var jetMenuAdmin = {
instance: [],
savedTimeout: null,
menuId: 0,
depth: 0,
saveHandlerId: 'jet_menu_save_options_ajax',
resetHandlerId: 'jet_menu_restore_options_ajax',
saveOptionsHandlerInstance: null,
resetOptionsHandlerInstance: null,
init: function() {
this.initTriggers();
$( document )
.on( 'click.jetMenuAdmin', '.jet-settings-tabs__nav-item ', this.switchTabs )
.on( 'click.jetMenuAdmin', '.jet-menu-editor', this.openEditor )
.on( 'click.jetMenuAdmin', '.jet-menu-trigger', this.initPopup )
.on( 'click.jetMenuAdmin', '.jet-menu-popup__overlay', this.closePopup )
.on( 'click.jetMenuAdmin', '.jet-close-frame', this.closeEditor )
.on( 'click.jetMenuAdmin', '.jet-save-menu', this.saveMenu )
.on( 'click.jetMenuAdmin', '.jet-menu-settins-save', this.saveSettins )
.on( 'click.jetMenuAdmin', '.jet-menu-import-btn', this.switchImportControl )
.on( 'click.jetMenuAdmin', '.jet-menu-run-import-btn', this.runImport )
.on( 'click.jetMenuAdmin', '#jet-menu-reset-options', this.resetOptions )
.on( 'click.jetMenuAdmin', '#jet-menu-create-preset', this.createPreset )
.on( 'click.jetMenuAdmin', '#jet-menu-update-preset', this.updatePreset )
.on( 'click.jetMenuAdmin', '#jet-menu-load-preset', this.loadPreset )
.on( 'click.jetMenuAdmin', '#jet-menu-delete-preset', this.deletePreset )
.on( 'click.jetMenuAdmin', '.jet-menu-popup__close', this.closePopup )
.on( 'focus.jetMenuAdmin', '.jet-preset-name', this.clearPresetError );
this.saveOptionsHandlerInstance = new CherryJsCore.CherryAjaxHandler(
{
handlerId: this.saveHandlerId,
successCallback: this.saveSuccessCallback.bind( this )
}
);
this.resetOptionsHandlerInstance = new CherryJsCore.CherryAjaxHandler(
{
handlerId: this.resetHandlerId,
successCallback: this.restoreSuccessCallback.bind( this )
}
);
this.addOptionPageEvents();
if ( 0 < $( '.cherry-tab__tabs-wrap' ).length ) {
var stickySidebar = new StickySidebar( '.cherry-tab__tabs-wrap', {
topSpacing: 55,
containerSelector: '.cherry-tab__tabs',
innerWrapperSelector: '.cherry-tab__tabs-wrap-content'
} );
}
},
createPreset: function() {
var $this = $( this ),
$input = $this.prev( '.cherry-ui-text' ),
$msg = $this.next( '.jet-preset-msg' ),
presetName = $input.val(),
fields = null,
data = {};
if ( '' === presetName ) {
$msg.addClass( 'jet-menu-error-message' ).text( settings.optionPageMessages.preset.nameError );
return;
}
data.action = 'jet_menu_create_preset';
data.name = presetName;
data.settings = CherryJsCore.cherryHandlerUtils.serializeObject( $( '#jet-menu-options-form' ) );
$this.prop( 'disabled', true );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: data
}).done( function( response ) {
if ( true === response.success ) {
$msg.text( settings.optionPageMessages.preset.created );
window.location = settings.menuPageUrl;
} else {
$this.prop( 'disabled', false );
$msg.addClass( 'jet-menu-error-message' ).text( response.data.message );
}
});
},
updatePreset: function() {
var $this = $( this ),
$select = $this.prev( '.cherry-ui-select' ),
$msg = $this.next( '.jet-preset-msg' ),
preset = $select.find( ':selected' ).val(),
fields = null,
data = {};
if ( '' === preset ) {
$msg.text( settings.optionPageMessages.preset.updateError );
return;
}
if ( confirm( settings.optionPageMessages.preset.confirmUpdate ) ) {
data.action = 'jet_menu_update_preset';
data.preset = preset;
data.settings = CherryJsCore.cherryHandlerUtils.serializeObject( $( '#jet-menu-options-form' ) );
$this.prop( 'disabled', true );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: data
}).done( function( response ) {
$msg.text( settings.optionPageMessages.preset.updated );
$this.prop( 'disabled', false );
setTimeout( function() {
$msg.empty();
}, 3000 );
});
}
},
loadPreset: function() {
var $this = $( this ),
$select = $this.prev( '.cherry-ui-select' ),
$msg = $this.next( '.jet-preset-msg' ),
preset = $select.find( ':selected' ).val(),
fields = null,
data = {};
if ( '' === preset ) {
$msg.text( settings.optionPageMessages.preset.loadError );
return;
}
if ( confirm( settings.optionPageMessages.preset.confirmLoad ) ) {
data.action = 'jet_menu_load_preset';
data.preset = preset;
$this.prop( 'disabled', true );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: data
}).done( function( response ) {
$msg.text( settings.optionPageMessages.preset.loaded );
window.location = settings.menuPageUrl;
});
}
},
deletePreset: function() {
var $this = $( this ),
$select = $this.prev( '.cherry-ui-select' ),
$msg = $this.next( '.jet-preset-msg' ),
preset = $select.find( ':selected' ).val(),
fields = null,
data = {};
if ( '' === preset ) {
$msg.text( settings.optionPageMessages.preset.deleteError );
return;
}
if ( confirm( settings.optionPageMessages.preset.confirmDelete ) ) {
data.action = 'jet_menu_delete_preset';
data.preset = preset;
$this.prop( 'disabled', true );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: data
}).done( function( response ) {
$msg.text( settings.optionPageMessages.preset.deleted );
window.location = settings.menuPageUrl;
});
}
},
clearPresetError: function() {
$( this ).siblings( '.jet-preset-msg' ).removeClass( 'jet-menu-error-message' ).text( '' );
},
resetOptions: function() {
if ( confirm( settings.optionPageMessages.resetMessage ) ) {
window.location = settings.resetUrl;
}
},
switchImportControl: function() {
$( this ).siblings( '.jet-menu-import' ).toggleClass( 'import-active' );
},
runImport: function() {
var $this = $( this ),
$fileInput = $this.siblings( '.jet-menu-import-file' ),
$messages = $this.siblings( '.jet-menu-import-messages' ),
file = $fileInput.val();
$messages.removeClass( 'jet-menu-error-message jet-menu-success-message' ).html( '' );
if ( ! file ) {
$messages.addClass( 'jet-menu-error-message' ).html( settings.optionPageMessages.emptyImportFile );
return;
}
var fileExt = file.split('.').pop().toLowerCase();
if ( 'json' !== fileExt ) {
$messages.addClass( 'jet-menu-error-message' ).html( settings.optionPageMessages.incorrectImportFile );
return;
}
var fileToLoad = $fileInput[0].files[0];
var fileReader = new FileReader();
$this.prop( 'disabled', true );
fileReader.onload = function( fileLoadedEvent ) {
var textFromFileLoaded = fileLoadedEvent.target.result;
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_menu_import_options',
data: JSON.parse( textFromFileLoaded )
},
}).done( function( response ) {
if ( true === response.success ) {
$messages.addClass( 'jet-menu-success-message' ).html( response.data.message );
window.location.reload();
} else {
$messages.addClass( 'jet-menu-error-message' ).html( response.data.message );
}
$this.prop( 'disabled', false );
});
};
fileReader.readAsText( fileToLoad, 'UTF-8' );
},
openEditor: function() {
var $popup = $( this ).closest( '.jet-menu-popup' ),
menuItem = $popup.attr( 'data-id' ),
url = settings.editURL.replace( '%id%', menuItem ),
frame = null,
loader = null,
editor = wp.template( 'editor-frame' );
url = url.replace( '%menuid%', settings.currentMenuId );
$popup
.addClass( 'jet-menu-editor-active' )
.find( '.jet-menu-editor-wrap' )
.addClass( 'jet-editor-active' )
.html( editor( { url: url } ) );
frame = $popup.find( '.jet-edit-frame' )[0];
loader = $popup.find( '#elementor-loading' );
$( frame.contentWindow ).load( function() {
$popup.find( '.jet-close-frame' ).addClass( 'jet-loaded' );
loader.fadeOut( 300 );
} );
},
initPopup: function() {
var $this = $( this ),
id = $this.data( 'item-id' ),
depth = $this.data( 'item-depth' ),
content = null,
wrapper = wp.template( 'popup-wrapper' ),
tabs = wp.template( 'popup-tabs' );
if ( ! jetMenuAdmin.instance[ id ] ) {
content = wrapper( {
id: id,
content: tabs( { tabs: settings.tabs, depth: depth } ),
saveLabel: settings.strings.saveLabel
} );
$( 'body' ).append( content );
jetMenuAdmin.instance[ id ] = '#jet-popup-' + id;
}
$( jetMenuAdmin.instance[ id ] ).removeClass( 'jet-hidden' );
jetMenuAdmin.menuId = id;
jetMenuAdmin.depth = depth;
jetMenuAdmin.tabs.showActive(
$( jetMenuAdmin.instance[ id ] ).find( '.jet-settings-tabs__nav-item:first' )
);
},
switchTabs: function() {
jetMenuAdmin.tabs.showActive( $( this ) );
},
saveSettins: function() {
var $this = $( this ),
$loader = $this.closest( '.submit' ).siblings( '.spinner' ),
$saved = $this.closest( '.submit' ).siblings( '.dashicons-yes' ),
data = [],
preparedData = {};
data = $( '.jet-menu-settings-fields input, .jet-menu-settings-fields select' ).serializeArray();
$.each( data, function( index, field ) {
preparedData[ field.name ] = field.value;
});
clearTimeout( jetMenuAdmin.savedTimeout );
$saved.addClass( 'hidden' );
$loader.css( 'visibility', 'visible' );
preparedData.action = 'jet_save_settings';
preparedData.current_menu = settings.currentMenuId;
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: preparedData
}).done( function( response ) {
$loader.css( 'visibility', 'hidden' );
if ( true === response.success ) {
$saved.removeClass( 'hidden' );
jetMenuAdmin.savedTimeout = setTimeout( function() {
$saved.addClass( 'hidden' );
}, 1000 );
}
});
},
saveMenu: function() {
var $this = $( this ),
$loader = $this.siblings( '.spinner' ),
$saved = $this.siblings( '.dashicons-yes' ),
data = [],
preparedData = {};
data = $( '.jet-settings-tabs__content input, .jet-settings-tabs__content select' ).serializeArray();
$.each( data, function( index, field ) {
preparedData[ field.name ] = field.value;
});
clearTimeout( jetMenuAdmin.savedTimeout );
$saved.addClass( 'hidden' );
$loader.css( 'visibility', 'visible' );
preparedData.action = 'jet_save_menu';
preparedData.menu_id = jetMenuAdmin.menuId;
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: preparedData
}).done( function( response ) {
$loader.css( 'visibility', 'hidden' );
if ( true === response.success ) {
$saved.removeClass( 'hidden' );
jetMenuAdmin.savedTimeout = setTimeout( function() {
$saved.addClass( 'hidden' );
}, 1000 );
}
});
},
tabs: {
showActive: function( $item ) {
var tab = $item.data( 'tab' ),
action = $item.data( 'action' ),
template = $item.data( 'template' ),
$content = $item.closest( '.jet-settings-tabs' ).find( '.jet-settings-tabs__content-item[data-tab="' + tab + '"]' ),
loaded = parseInt( $content.data( 'loaded' ) );
if ( $item.hasClass( 'jet-active-tab' ) ) {
return;
}
if ( 0 === loaded ) {
jetMenuAdmin.tabs.loadTabContent( tab, $content, template, action );
}
$item.addClass( 'jet-active-tab' ).siblings().removeClass( 'jet-active-tab' );
$content.removeClass( 'jet-hidden-tab' ).siblings().addClass( 'jet-hidden-tab' );
},
loadTabContent: function( tab, $content, template, action ) {
if ( ! template && ! action ) {
return;
}
var renderTemplate = null,
$popup = $content.closest( '.jet-menu-popup' ),
id = $popup.attr( 'data-id' ),
data = {};
$content.has( '.tab-loader' ).addClass( 'tab-loading' );
if ( ! template ) {
if ( 0 < settings.tabs[ tab ].data.length ) {
data = settings.tabs[ tab ].data;
data.action = action;
data.menu_id = id;
} else {
data = {
action: action,
menu_id: id
};
}
$.ajax({
url: ajaxurl,
type: 'get',
dataType: 'json',
data: data
}).done( function( response ) {
if ( true === response.success ) {
$content.removeClass( 'tab-loading' ).html( response.data.content );
if ( CherryJsCore.ui_elements.iconpicker && window.cherry5IconSets ) {
CherryJsCore.ui_elements.iconpicker.setIconsSets( window.cherry5IconSets );
}
$( 'body' ).trigger( {
type: 'cherry-ui-elements-init',
_target: $content
} );
}
});
} else {
renderTemplate = wp.template( template );
$content.html( renderTemplate( settings.tabs[ tab ].data ) );
}
$content.data( 'loaded', 1 );
}
},
closePopup: function( event ) {
event.preventDefault();
jetMenuAdmin.menuId = 0;
jetMenuAdmin.depth = 0;
$( this )
.closest( '.jet-menu-popup' ).addClass( 'jet-hidden' )
.removeClass( 'jet-menu-editor-active' )
.find( '.jet-menu-editor-wrap.jet-editor-active' ).removeClass( 'jet-editor-active' )
.find( '.jet-close-frame' ).removeClass( 'jet-loaded' )
.siblings( '#elementor-loading' ).fadeIn( 0 );
},
closeEditor: function( event ) {
var $this = $( this ),
$popup = $this.closest( '.jet-menu-popup' ),
$frame = $( this ).siblings( 'iframe' ),
$loader = $popup.find( '#elementor-loading' ),
$editor = $frame.closest( '.jet-menu-editor-wrap' ),
$content = $frame[0].contentWindow,
saver = null,
enabled = true;
if ( $content.elementor.saver && 'function' === typeof $content.elementor.saver.isEditorChanged ) {
saver = $content.elementor.saver;
} else if ( 'function' === typeof $content.elementor.isEditorChanged ) {
saver = $content.elementor;
}
if ( null !== saver && true === saver.isEditorChanged() ) {
if ( ! confirm( settings.strings.leaveEditor ) ) {
enabled = false;
}
}
if ( ! enabled ) {
return;
}
$loader.fadeIn(0);
$popup.removeClass( 'jet-menu-editor-active' );
$this.removeClass( 'jet-loaded' );
$editor.removeClass( 'jet-editor-active' );
},
getItemId: function( $item ) {
var id = $item.attr( 'id' );
return id.replace( 'menu-item-', '' );
},
getItemDepth: function( $item ) {
var depthClass = $item.attr( 'class' ).match( /menu-item-depth-\d/ );
if ( ! depthClass[0] ) {
return 0;
}
return depthClass[0].replace( 'menu-item-depth-', '' );
},
initTriggers: function() {
var trigger = wp.template( 'menu-trigger' );
$( document ).on( 'menu-item-added', function( event, $menuItem ) {
var id = jetMenuAdmin.getItemId( $menuItem );
$menuItem.find( '.item-title' ).append( trigger( { id: id, label: settings.strings.triggerLabel } ) );
});
$( '#menu-to-edit .menu-item' ).each( function() {
var $this = $( this ),
depth = jetMenuAdmin.getItemDepth( $this ),
id = jetMenuAdmin.getItemId( $this );
$this.find( '.item-title' ).append( trigger( {
id: id,
depth: depth,
label: settings.strings.triggerLabel
} ) );
});
},
addOptionPageEvents: function() {
$( 'body' )
.on( 'click', '#jet-menu-save-options', this.saveOptionsHandler.bind( this ) )
.on( 'click', '#jet-menu-restore-options', this.resetOptionsHandler.bind( this ) );
},
saveOptionsHandler: function( event ) {
this.disableFormButton( event.target );
this.saveOptionsHandlerInstance.sendFormData( '#jet-menu-options-form' );
},
resetOptionsHandler: function( event ) {
this.disableFormButton( event.target );
this.resetOptionsHandlerInstance.send();
},
saveSuccessCallback: function() {
this.enableFormButton( '#jet-menu-save-options' );
CherryJsCore.cherryHandlerUtils.noticeCreate( 'success-notice', window.jetMenuAdminSettings.optionPageMessages.saveMessage );
},
restoreSuccessCallback: function() {
this.enableFormButton( '#jet-menu-restore-options' );
CherryJsCore.cherryHandlerUtils.noticeCreate( 'success-notice', window.jetMenuAdminSettings.optionPageMessages.restoreMessage );
setTimeout( function() {
window.location.href = window.jetMenuAdminSettings.optionPageMessages.redirectUrl;
}, 500 );
},
disableFormButton: function( button ) {
$( button )
.attr( 'disabled', 'disabled' );
},
enableFormButton: function( button ) {
var timer = null;
$( button )
.removeAttr( 'disabled' )
.addClass( 'success' );
timer = setTimeout(
function() {
$( button ).removeClass( 'success' );
clearTimeout( timer );
},
1000
);
}
};
jetMenuAdmin.init();
}( jQuery, window.jetMenuAdminSettings ) );

View File

@@ -0,0 +1,776 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Sticky Sidebar JavaScript Plugin.
* @version 3.2.0
* @author Ahmed Bouhuolia <a.bouhuolia@gmail.com>
* @license The MIT License (MIT)
*/
var StickySidebar = function () {
// ---------------------------------
// # Define Constants
// ---------------------------------
//
var EVENT_KEY = '.stickySidebar';
var DEFAULTS = {
/**
* Additional top spacing of the element when it becomes sticky.
* @type {Numeric|Function}
*/
topSpacing: 0,
/**
* Additional bottom spacing of the element when it becomes sticky.
* @type {Numeric|Function}
*/
bottomSpacing: 0,
/**
* Container sidebar selector to know what the beginning and end of sticky element.
* @type {String|False}
*/
containerSelector: false,
/**
* Inner wrapper selector.
* @type {String}
*/
innerWrapperSelector: '.inner-wrapper-sticky',
/**
* The name of CSS class to apply to elements when they have become stuck.
* @type {String|False}
*/
stickyClass: 'is-affixed',
/**
* Detect when sidebar and its container change height so re-calculate their dimensions.
* @type {Boolean}
*/
resizeSensor: true,
/**
* The sidebar returns to its normal position if its width below this value.
* @type {Numeric}
*/
minWidth: false
};
// ---------------------------------
// # Class Definition
// ---------------------------------
//
/**
* Sticky Sidebar Class.
* @public
*/
var StickySidebar = function () {
/**
* Sticky Sidebar Constructor.
* @constructor
* @param {HTMLElement|String} sidebar - The sidebar element or sidebar selector.
* @param {Object} options - The options of sticky sidebar.
*/
function StickySidebar(sidebar) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, StickySidebar);
this.options = StickySidebar.extend(DEFAULTS, options);
// Sidebar element query if there's no one, throw error.
this.sidebar = 'string' === typeof sidebar ? document.querySelector(sidebar) : sidebar;
if ('undefined' === typeof this.sidebar) throw new Error("There is no specific sidebar element.");
this.sidebarInner = false;
this.container = this.sidebar.parentElement;
// Current Affix Type of sidebar element.
this.affixedType = 'STATIC';
this.direction = 'down';
this.support = {
transform: false,
transform3d: false
};
this._initialized = false;
this._breakpoint = false;
this._resizeListeners = [];
// Dimenstions of sidebar, container and screen viewport.
this.dimensions = {
translateY: 0,
topSpacing: 0,
bottomSpacing: 0,
sidebarHeight: 0,
sidebarWidth: 0,
containerTop: 0,
containerHeight: 0,
viewportHeight: 0,
viewportTop: 0,
lastViewportTop: 0
};
// Bind event handlers for referencability.
['handleEvent'].forEach(function (method) {
_this[method] = _this[method].bind(_this);
});
// Initialize sticky sidebar for first time.
this.initialize();
}
/**
* Initializes the sticky sidebar by adding inner wrapper, define its container,
* min-width breakpoint, calculating dimenstions, adding helper classes and inline style.
* @private
*/
_createClass(StickySidebar, [{
key: 'initialize',
value: function initialize() {
var _this2 = this;
this._setSupportFeatures();
// Get sticky sidebar inner wrapper, if not found, will create one.
if (this.options.innerWrapperSelector) {
this.sidebarInner = this.sidebar.querySelector(this.options.innerWrapperSelector);
if (null === this.sidebarInner) this.sidebarInner = false;
}
if (!this.sidebarInner) {
var wrapper = document.createElement('div');
wrapper.setAttribute('class', 'inner-wrapper-sticky');
this.sidebar.appendChild(wrapper);
while (this.sidebar.firstChild != wrapper) {
wrapper.appendChild(this.sidebar.firstChild);
}this.sidebarInner = this.sidebar.querySelector('.inner-wrapper-sticky');
}
// Container wrapper of the sidebar.
if (this.options.containerSelector) {
var containers = document.querySelectorAll(this.options.containerSelector);
containers = Array.prototype.slice.call(containers);
containers.forEach(function (container, item) {
if (!container.contains(_this2.sidebar)) return;
_this2.container = container;
});
if (!containers.length) throw new Error("The container does not contains on the sidebar.");
}
// If top/bottom spacing is not function parse value to integer.
if ('function' !== typeof this.options.topSpacing) this.options.topSpacing = parseInt(this.options.topSpacing) || 0;
if ('function' !== typeof this.options.bottomSpacing) this.options.bottomSpacing = parseInt(this.options.bottomSpacing) || 0;
// Breakdown sticky sidebar if screen width below `options.minWidth`.
this._widthBreakpoint();
// Calculate dimensions of sidebar, container and viewport.
this.calcDimensions();
// Affix sidebar in proper position.
this.stickyPosition();
// Bind all events.
this.bindEvents();
// Inform other properties the sticky sidebar is initialized.
this._initialized = true;
}
/**
* Bind all events of sticky sidebar plugin.
* @protected
*/
}, {
key: 'bindEvents',
value: function bindEvents() {
window.addEventListener('resize', this, { passive: true });
window.addEventListener('scroll', this, { passive: true });
this.sidebar.addEventListener('update' + EVENT_KEY, this);
if (this.options.resizeSensor && 'undefined' !== typeof ResizeSensor) {
new ResizeSensor(this.sidebarInner, this.handleEvent);
new ResizeSensor(this.container, this.handleEvent);
}
}
/**
* Handles all events of the plugin.
* @param {Object} event - Event object passed from listener.
*/
}, {
key: 'handleEvent',
value: function handleEvent(event) {
this.updateSticky(event);
}
/**
* Calculates dimesntions of sidebar, container and screen viewpoint
* @public
*/
}, {
key: 'calcDimensions',
value: function calcDimensions() {
if (this._breakpoint) return;
var dims = this.dimensions;
// Container of sticky sidebar dimensions.
dims.containerTop = StickySidebar.offsetRelative(this.container).top;
dims.containerHeight = this.container.clientHeight;
dims.containerBottom = dims.containerTop + dims.containerHeight;
// Sidebar dimensions.
dims.sidebarHeight = this.sidebarInner.offsetHeight;
dims.sidebarWidth = this.sidebar.offsetWidth;
// Screen viewport dimensions.
dims.viewportHeight = window.innerHeight;
this._calcDimensionsWithScroll();
}
/**
* Some dimensions values need to be up-to-date when scrolling the page.
* @private
*/
}, {
key: '_calcDimensionsWithScroll',
value: function _calcDimensionsWithScroll() {
var dims = this.dimensions;
dims.sidebarLeft = StickySidebar.offsetRelative(this.sidebar).left;
dims.viewportTop = document.documentElement.scrollTop || document.body.scrollTop;
dims.viewportBottom = dims.viewportTop + dims.viewportHeight;
dims.viewportLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
dims.topSpacing = this.options.topSpacing;
dims.bottomSpacing = this.options.bottomSpacing;
if ('function' === typeof dims.topSpacing) dims.topSpacing = parseInt(dims.topSpacing(this.sidebar)) || 0;
if ('function' === typeof dims.bottomSpacing) dims.bottomSpacing = parseInt(dims.bottomSpacing(this.sidebar)) || 0;
}
/**
* Detarmine wheather the sidebar is bigger than viewport.
* @public
* @return {Boolean}
*/
}, {
key: 'isSidebarFitsViewport',
value: function isSidebarFitsViewport() {
return this.dimensions.sidebarHeight < this.dimensions.viewportHeight;
}
/**
* Observe browser scrolling direction top and down.
*/
}, {
key: 'observeScrollDir',
value: function observeScrollDir() {
var dims = this.dimensions;
if (dims.lastViewportTop === dims.viewportTop) return;
var furthest = 'down' === this.direction ? Math.min : Math.max;
// If the browser is scrolling not in the same direction.
if (dims.viewportTop === furthest(dims.viewportTop, dims.lastViewportTop)) this.direction = 'down' === this.direction ? 'up' : 'down';
}
/**
* Gets affix type of sidebar according to current scrollTop and scrollLeft.
* Holds all logical affix of the sidebar when scrolling up and down and when sidebar
* is bigger than viewport and vice versa.
* @public
* @return {String|False} - Proper affix type.
*/
}, {
key: 'getAffixType',
value: function getAffixType() {
var dims = this.dimensions,
affixType = false;
this._calcDimensionsWithScroll();
var sidebarBottom = dims.sidebarHeight + dims.containerTop;
var colliderTop = dims.viewportTop + dims.topSpacing;
var colliderBottom = dims.viewportBottom - dims.bottomSpacing;
// When browser is scrolling top.
if ('up' === this.direction) {
if (colliderTop <= dims.containerTop) {
dims.translateY = 0;
affixType = 'STATIC';
} else if (colliderTop <= dims.translateY + dims.containerTop) {
dims.translateY = colliderTop - dims.containerTop;
affixType = 'VIEWPORT-TOP';
} else if (!this.isSidebarFitsViewport() && dims.containerTop <= colliderTop) {
affixType = 'VIEWPORT-UNBOTTOM';
}
// When browser is scrolling up.
} else {
// When sidebar element is not bigger than screen viewport.
if (this.isSidebarFitsViewport()) {
if (dims.sidebarHeight + colliderTop >= dims.containerBottom) {
dims.translateY = dims.containerBottom - sidebarBottom;
affixType = 'CONTAINER-BOTTOM';
} else if (colliderTop >= dims.containerTop) {
dims.translateY = colliderTop - dims.containerTop;
affixType = 'VIEWPORT-TOP';
}
// When sidebar element is bigger than screen viewport.
} else {
if (dims.containerBottom <= colliderBottom) {
dims.translateY = dims.containerBottom - sidebarBottom;
affixType = 'CONTAINER-BOTTOM';
} else if (sidebarBottom + dims.translateY <= colliderBottom) {
dims.translateY = colliderBottom - sidebarBottom;
affixType = 'VIEWPORT-BOTTOM';
} else if (dims.containerTop + dims.translateY <= colliderTop) {
affixType = 'VIEWPORT-UNBOTTOM';
}
}
}
// Make sure the translate Y is not bigger than container height.
dims.translateY = Math.max(0, dims.translateY);
dims.translateY = Math.min(dims.containerHeight, dims.translateY);
dims.lastViewportTop = dims.viewportTop;
return affixType;
}
/**
* Gets inline style of sticky sidebar wrapper and inner wrapper according
* to its affix type.
* @private
* @param {String} affixType - Affix type of sticky sidebar.
* @return {Object}
*/
}, {
key: '_getStyle',
value: function _getStyle(affixType) {
if ('undefined' === typeof affixType) return;
var style = { inner: {}, outer: {} };
var dims = this.dimensions;
switch (affixType) {
case 'VIEWPORT-TOP':
style.inner = { position: 'fixed', top: this.options.topSpacing,
left: dims.sidebarLeft - dims.viewportLeft, width: dims.sidebarWidth };
break;
case 'VIEWPORT-BOTTOM':
style.inner = { position: 'fixed', top: 'auto', left: dims.sidebarLeft,
bottom: this.options.bottomSpacing, width: dims.sidebarWidth };
break;
case 'CONTAINER-BOTTOM':
case 'VIEWPORT-UNBOTTOM':
var translate = this._getTranslate(0, dims.translateY + 'px');
if (translate) style.inner = { transform: translate };else style.inner = { position: 'absolute', top: dims.translateY, width: dims.sidebarWidth };
break;
}
switch (affixType) {
case 'VIEWPORT-TOP':
case 'VIEWPORT-BOTTOM':
case 'VIEWPORT-UNBOTTOM':
case 'CONTAINER-BOTTOM':
style.outer = { height: dims.sidebarHeight, position: 'relative' };
break;
}
style.outer = StickySidebar.extend({ height: '', position: '' }, style.outer);
style.inner = StickySidebar.extend({ position: 'relative', top: '', left: '',
bottom: '', width: '', transform: this._getTranslate() }, style.inner);
return style;
}
/**
* Cause the sidebar to be sticky according to affix type by adding inline
* style, adding helper class and trigger events.
* @function
* @protected
* @param {string} force - Update sticky sidebar position by force.
*/
}, {
key: 'stickyPosition',
value: function stickyPosition(force) {
if (this._breakpoint) return;
force = force || false;
var affixType = this.getAffixType();
var style = this._getStyle(affixType);
if ((this.affixedType != affixType || force) && affixType) {
var affixEvent = 'affix.' + affixType.toLowerCase().replace('viewport-', '') + EVENT_KEY;
StickySidebar.eventTrigger(this.sidebar, affixEvent);
if ('STATIC' === affixType) StickySidebar.removeClass(this.sidebar, this.options.stickyClass);else StickySidebar.addClass(this.sidebar, this.options.stickyClass);
for (var key in style.outer) {
this.sidebar.style[key] = style.outer[key];
}
for (var _key in style.inner) {
var _unit2 = 'number' === typeof style.inner[_key] ? 'px' : '';
this.sidebarInner.style[_key] = style.inner[_key] + _unit2;
}
var affixedEvent = 'affixed.' + affixType.toLowerCase().replace('viewport', '') + EVENT_KEY;
StickySidebar.eventTrigger(this.sidebar, affixedEvent);
} else {
if (this._initialized) this.sidebarInner.style.left = style.inner.left;
}
this.affixedType = affixType;
}
/**
* Breakdown sticky sidebar when window width is below `options.minWidth` value.
* @protected
*/
}, {
key: '_widthBreakpoint',
value: function _widthBreakpoint() {
if (window.innerWidth <= this.options.minWidth) {
this._breakpoint = true;
this.affixedType = 'STATIC';
this.sidebar.removeAttribute('style');
StickySidebar.removeClass(this.sidebar, this.options.stickyClass);
this.sidebarInner.removeAttribute('style');
} else {
this._breakpoint = false;
}
}
/**
* Switchs between functions stack for each event type, if there's no
* event, it will re-initialize sticky sidebar.
* @public
*/
}, {
key: 'updateSticky',
value: function updateSticky() {
var _this3 = this;
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (this._running) return;
this._running = true;
(function (eventType) {
requestAnimationFrame(function () {
switch (eventType) {
// When browser is scrolling and re-calculate just dimensions
// within scroll.
case 'scroll':
_this3._calcDimensionsWithScroll();
_this3.observeScrollDir();
_this3.stickyPosition();
break;
// When browser is resizing or there's no event, observe width
// breakpoint and re-calculate dimensions.
case 'resize':
default:
_this3._widthBreakpoint();
_this3.calcDimensions();
_this3.stickyPosition(true);
break;
}
_this3._running = false;
});
})(event.type);
}
/**
* Set browser support features to the public property.
* @private
*/
}, {
key: '_setSupportFeatures',
value: function _setSupportFeatures() {
var support = this.support;
support.transform = StickySidebar.supportTransform();
support.transform3d = StickySidebar.supportTransform(true);
}
/**
* Get translate value, if the browser supports transfrom3d, it will adopt it.
* and the same with translate. if browser doesn't support both return false.
* @param {Number} y - Value of Y-axis.
* @param {Number} x - Value of X-axis.
* @param {Number} z - Value of Z-axis.
* @return {String|False}
*/
}, {
key: '_getTranslate',
value: function _getTranslate() {
var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
if (this.support.transform3d) return 'translate3d(' + y + ', ' + x + ', ' + z + ')';else if (this.support.translate) return 'translate(' + y + ', ' + x + ')';else return false;
}
/**
* Destroy sticky sidebar plugin.
* @public
*/
}, {
key: 'destroy',
value: function destroy() {
window.removeEventListener('resize', this);
window.removeEventListener('scroll', this);
this.sidebar.classList.remove(this.options.stickyClass);
this.sidebar.style.minHeight = '';
this.sidebar.removeEventListener('update' + EVENT_KEY, this);
var styleReset = { inner: {}, outer: {} };
styleReset.inner = { position: '', top: '', left: '', bottom: '', width: '', transform: '' };
styleReset.outer = { height: '', position: '' };
for (var key in styleReset.outer) {
this.sidebar.style[key] = styleReset.outer[key];
}for (var _key2 in styleReset.inner) {
this.sidebarInner.style[_key2] = styleReset.inner[_key2];
}if (this.options.resizeSensor && 'undefined' !== typeof ResizeSensor) {
ResizeSensor.detach(this.sidebarInner, this.handleEvent);
ResizeSensor.detach(this.container, this.handleEvent);
}
}
/**
* Detarmine if the browser supports CSS transfrom feature.
* @function
* @static
* @param {Boolean} transform3d - Detect transform with translate3d.
* @return {String}
*/
}], [{
key: 'supportTransform',
value: function supportTransform(transform3d) {
var result = false,
property = transform3d ? 'perspective' : 'transform',
upper = property.charAt(0).toUpperCase() + property.slice(1),
prefixes = ['Webkit', 'Moz', 'O', 'ms'],
support = document.createElement('support'),
style = support.style;
(property + ' ' + prefixes.join(upper + ' ') + upper).split(' ').forEach(function (property, i) {
if (style[property] !== undefined) {
result = property;
return false;
}
});
return result;
}
/**
* Trigger custom event.
* @static
* @param {DOMObject} element - Target element on the DOM.
* @param {String} eventName - Event name.
* @param {Object} data -
*/
}, {
key: 'eventTrigger',
value: function eventTrigger(element, eventName, data) {
try {
var event = new CustomEvent(eventName, { detail: data });
} catch (e) {
var event = document.createEvent('CustomEvent');
event.initCustomEvent(eventName, true, true, data);
}
element.dispatchEvent(event);
}
/**
* Extend options object with defaults.
* @function
* @static
*/
}, {
key: 'extend',
value: function extend(defaults, options) {
var results = {};
for (var key in defaults) {
if ('undefined' !== typeof options[key]) results[key] = options[key];else results[key] = defaults[key];
}
return results;
}
/**
* Get current coordinates left and top of specific element.
* @static
*/
}, {
key: 'offsetRelative',
value: function offsetRelative(element) {
var result = { left: 0, top: 0 };
do {
var offsetTop = element.offsetTop;
var offsetLeft = element.offsetLeft;
if (!isNaN(offsetTop)) result.top += offsetTop;
if (!isNaN(offsetLeft)) result.left += offsetLeft;
} while (element = element.offsetParent);
return result;
}
/**
* Add specific class name to specific element.
* @static
* @param {ObjectDOM} element
* @param {String} className
*/
}, {
key: 'addClass',
value: function addClass(element, className) {
if (!StickySidebar.hasClass(element, className)) {
if (element.classList) element.classList.add(className);else element.className += ' ' + className;
}
}
/**
* Remove specific class name to specific element
* @static
* @param {ObjectDOM} element
* @param {String} className
*/
}, {
key: 'removeClass',
value: function removeClass(element, className) {
if (StickySidebar.hasClass(element, className)) {
if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}
}
/**
* Detarmine weather the element has specific class name.
* @static
* @param {ObjectDOM} element
* @param {String} className
*/
}, {
key: 'hasClass',
value: function hasClass(element, className) {
if (element.classList) return element.classList.contains(className);else return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
}
}]);
return StickySidebar;
}();
return StickySidebar;
}();
// Global
// -------------------------
window.StickySidebar = StickySidebar;
(function () {
if ('undefined' === typeof window) return;
var plugin = window.$ || window.jQuery || window.Zepto;
var DATA_NAMESPACE = 'stickySidebar';
// Make sure the site has jquery or zepto plugin.
if (plugin) {
/**
* Sticky Sidebar Plugin Defintion.
* @param {Object|String} - config
*/
var _jQueryPlugin = function (config) {
return this.each(function () {
var $this = plugin(this),
data = plugin(this).data(DATA_NAMESPACE);
if (!data) {
data = new StickySidebar(this, typeof config == 'object' && config);
$this.data(DATA_NAMESPACE, data);
}
if ('string' === typeof config) {
if (data[config] === undefined && ['destroy', 'updateSticky'].indexOf(config) === -1) throw new Error('No method named "' + config + '"');
data[config]();
}
});
};
plugin.fn.stickySidebar = _jQueryPlugin;
plugin.fn.stickySidebar.Constructor = StickySidebar;
var old = plugin.fn.stickySidebar;
/**
* Sticky Sidebar No Conflict.
*/
plugin.fn.stickySidebar.noConflict = function () {
plugin.fn.stickySidebar = old;
return this;
};
}
})();
})));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,168 @@
$padding: 10px;
.jet_menu_options_section {
max-width: 1200px;
}
.cherry-tab__tabs-wrap {
width: 100%;
.cherry-tab__tabs-wrap-content {
display: flex;
flex-wrap: wrap;
}
}
.jet-preset-msg {
color: #49c66a;
}
.jet-menu-success-message {
padding-top: 5px;
color: #49c66a;
}
.jet-menu-error-message {
padding-top: 5px;
color: #f00;
}
.option-page-footer {
padding: $padding;
.cherry-settings__content {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.cherry-ui-kit.jet-menu-import-export {
flex: 1;
br {
width: 100%;
display: block;
height: 0;
line-height: 0;
}
}
.jet-menu-import {
height: 0;
overflow: hidden;
&__inner {
border-radius: 5px;
padding: 0;
height: 0;
margin-top: 0;
overflow: hidden;
display: inline-block;
}
&.import-active {
height: auto;
.jet-menu-import__inner {
height: auto;
border: 1px solid rgba(0,0,0,0.1);
margin-top: 20px;
padding: 20px;
}
}
}
@media ( min-width: 783px ) {
padding: $padding * 1.5;
}
@media ( min-width: 961px ) {
padding: $padding * 3;
}
button {
margin-left: 10px;
position: relative;
&:first-child{
margin-left: 0;
}
}
}
button.cherry5-ui-button {
.text {
transition: opacity 0.7s ease;
}
.icon, .loader-wrapper {
opacity: 0;
transform: scale(0);
transition: opacity 0.5s ease, transform 0.5s ease;
}
.icon {
position: absolute;
top: 50%;
left: 50%;
font-size: 20px;
width: 20px;
height: 20px;
margin: -10px 0 0 -10px;
}
.loader-wrapper {
position: absolute;
top: 50%;
left: 50%;
width: 12px;
height: 12px;
margin: -9px 0 0 -8px;
}
.loader {
width: 12px;
height: 12px;
border: 3px solid #ffffff;
border-top: 3px solid #3498db;
border-radius: 50%;
display: block;
animation: spin 0.7s linear infinite;
}
&[disabled], &.success {
cursor: default;
pointer-events: none;
.text{
opacity: 0;
}
}
&[disabled] {
.loader-wrapper {
opacity: 1;
transform: scale(1);
}
}
&.success {
.icon {
opacity: 1;
transform: scale(1);
transition-delay: 0.1s;
}
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
}
.jet-delete-preset-wrap {
color: #a00;
.cherry-ui-kit__description {
color: #a00;
}
}
.cherry-ui-control-preset-wrapper {
.cherry-ui-text,
.cherry-ui-select {
vertical-align: top;
margin-top: 0;
margin-right: 10px;
width: 250px;
}
.cherry5-ui-button {
vertical-align: top;
width: 90px;
}
}

View File

@@ -0,0 +1,494 @@
@import "option-page-styles";
$primary_color: #298ffc;
$primary_color_hover: #206ff4;
$border_color: #e5e5e5;
$text_color: #96989a;
$actions_color: #495157;
$actions_height: 40px;
.jet-menu-trigger {
cursor: pointer;
display: inline-block;
padding: 3px 5px;
background: $primary_color;
color: #fff;
font-weight: normal;
font-size: 11px;
line-height: 16px;
overflow: hidden;
vertical-align: middle;
margin: -4px -25px 0 5px;
transition: all 300ms cubic-bezier(.31,.91,.51,1);
opacity: 0;
&:hover {
background: $primary_color_hover;
}
.dashicons {
float: left;
font-size: 12px;
line-height: 16px;
width: 16px;
height: 16px;
}
.menu-item:hover & {
opacity: 1;
}
}
.jet-menu-popup {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 99999;
background: rgba(0,0,0,.6);
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
opacity: 1;
color: $text_color;
&.jet-hidden {
top: auto;
height: 0;
opacity: 0;
transition: opacity 150ms linear;
.jet-menu-popup__content {
opacity: 0;
transform: translateY(30px);
}
}
&__overlay {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 1;
}
&__content {
background: #fff;
display: inline-block;
box-shadow: 0px 5px 21px rgba(0,0,0,0.3);
box-sizing: border-box;
opacity: 1;
transform: translateY(0);
transition: all 300ms linear 200ms;
position: relative;
z-index: 2;
width: 850px;
height: 400px;
max-width: 90vw;
overflow: auto;
.jet-menu-editor-active & {
transition: all 300ms cubic-bezier(.31,.91,.51,1);
width: 90vw;
height: 90vh;
}
}
&-close {
position: absolute;
right: -40px;
top: -8px;
width: 30px;
height: 30px;
line-height: 30px;
text-align: center;
font-size: 34px;
color: rgba( 255,255,255,.7 );
cursor: pointer;
&:hover {
color: rgba( 255,255,255,1 );
}
}
&__inner {
height: calc( 100% - 40px );
}
&__actions {
height: $actions_height;
display: flex;
justify-content: space-between;
align-items: center;
background: $actions_color;
.spinner {
float: none;
background-image: url( '../images/loader.gif' );
margin-top: 0;
margin-right: 6px;
}
&-save {
display: flex;
padding-right: 5px;
align-items: center;
.dashicons {
margin-right: 8px;
margin-top: 2px;
}
}
}
&__close {
width: $actions_height;
height: $actions_height;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: rgba( 255, 255, 255, .3 );
&:hover {
color: rgba( 255, 255, 255, .6 );
}
}
.cherry5-ui-button {
&.button-hero {
padding: 15px 30px;
font-size: 14px;
}
}
}
.jet-settings-tabs {
display: flex;
align-items: stretch;
height: 100%;
&__nav {
width: 17%;
min-width: 120px;
border-right: 1px solid $border_color;
text-align: right;
padding-top: 20px;
&-item {
cursor: pointer;
line-height: 17px;
padding: 10px 20px;
font-weight: 700;
font-size: 14px;
color: #23282d;
position: relative;
transition: all 150ms linear;
&:after {
transition: all 150ms linear;
position: absolute;
left: 100%;
top: 0;
bottom: 0;
content: "";
width: 0;
background: $primary_color;
}
&:hover,
&.jet-active-tab {
color: $primary_color;
&:after {
width: 3px;
}
}
}
}
&__content {
flex-grow: 1;
&-item {
padding: 20px 0;
height: 100%;
box-sizing: border-box;
overflow: auto;
&::-webkit-scrollbar {
width: 5px;
}
&::-webkit-scrollbar-track {
background: rgba( 0,0,0, .05 );
}
&::-webkit-scrollbar-thumb {
background: rgba( 0,0,0, .2 );
border-radius: 5px;
}
.iconpicker-popover {
left: 0 !important;
}
&.tab-loading {
display: flex;
justify-content: center;
align-items: center;
}
.jet-content-tab-wrap {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 400px;
max-height: 100%;
text-align: center;
}
> .cherry-ui-container {
margin: 0;
padding: 10px 25px 17px;
border-top: 1px solid $border_color;
&:first-child {
border-top: none;
}
}
.iconpicker-popover.popover {
z-index: 1001;
}
.wp-picker-container.wp-picker-active {
z-index: 1001;
}
}
}
}
.jet-hidden-tab {
display: none;
}
.jet-menu-editor-wrap {
display: none;
&.jet-editor-active {
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
.jet-editor-frame {
width: 100%;
height: 100%;
min-height: 100%;
position: relative;
}
iframe {
width: 100%;
height: 100%;
}
}
}
.jet-close-frame {
display: none;
&.jet-loaded {
display: block;
}
.back-arrow-top {
position: absolute;
z-index: 9999;
width: 40px;
height: 40px;
left: 0;
top: 0;
cursor: pointer;
}
.back-arrow-bottom {
position: absolute;
z-index: 9999;
width: 50px;
height: 39px;
left: 0;
bottom: 0;
cursor: pointer;
}
}
#elementor-loading {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #f1f3f5;
z-index: 9999;
}
.elementor-loader-wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
width: 100px;
.elementor-loader {
height: 90px;
position: relative;
}
.elementor-loader-box {
background-color: #495157;
}
.elementor-loader-box {
position: absolute;
animation: load 1.8s linear infinite;
}
.elementor-loader-box:nth-of-type(1) {
width: 23%;
height: 100%;
left: 0;
top: 0;
}
.elementor-loader-box:not(:nth-of-type(1)) {
right: 0;
height: 20%;
width: 60%;
}
.elementor-loader-box:nth-of-type(2) {
top: 0;
animation-delay: -0.45s;
}
.elementor-loader-box:nth-of-type(3) {
top: 40%;
animation-delay: -0.9s;
}
.elementor-loader-box:nth-of-type(4) {
bottom: 0;
animation-delay: -1.35s;
}
}
.jet-menu-settings-fields + p.submit {
margin: 0;
padding: 0;
}
.tab-loader,
.tab-loader:after {
border-radius: 50%;
width: 40px;
height: 40px;
}
.tab-loader {
font-size: 10px;
position: relative;
text-indent: -9999em;
border-top: 3px solid rgba( 0, 0, 0, 0.1);
border-right: 3px solid rgba( 0, 0, 0, 0.1);
border-bottom: 3px solid rgba( 0, 0, 0, 0.1);
border-left: 3px solid rgba( 0, 0, 0, 0.5);
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-animation: loader 1.1s infinite linear;
animation: loader 1.1s infinite linear;
}
.jet_menu_options_section {
.cherry-component.cherry-tab .cherry-tab__tabs .cherry-component__button {
padding-right: 20px;
}
.cherry-component.cherry-tab--vertical > .cherry-tab__body > .cherry-tab__tabs {
padding-top: 23px;
padding-bottom: 23px;
}
.cherry-control__title {
margin: 0;
}
@media ( min-width: 783px ) {
.cherry-control__info {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.cherry-control__title {
flex: 1 0 100%;
}
.cherry-control__description {
flex: 1 0 100%;
}
}
.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result span {
border-radius: 3px;
border: 3px solid #fff;
box-sizing: border-box;
}
.cherry-ui-select,
.select2 {
background: #f0f0f0;
max-width: 382px;
}
}
@-webkit-keyframes load {
0% {
opacity: .3;
}
50% {
opacity: 1;
}
100% {
opacity: .3;
}
}
@keyframes load {
0% {
opacity: .3;
}
50% {
opacity: 1;
}
100% {
opacity: .3;
}
}
.elementor-loading-title {
color: #495157;
text-align: center;
text-transform: uppercase;
margin-top: 30px;
letter-spacing: 7px;
font-size: 10px;
animation: load-title 1.5s linear infinite;
}
@-webkit-keyframes load-title {
0% {
opacity: 1;
}
50% {
opacity: .6;
}
100% {
opacity: 1;
}
}
@keyframes load-title {
0% {
opacity: 1;
}
50% {
opacity: .6;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes loader {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes loader {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

View File

@@ -0,0 +1,40 @@
.elementor-panel {
.elementor-header-button {
.elementor-icon.eicon-menu-bar {
font-size: 20px;
&:before {
content: '\E87E';
}
}
}
#elementor-panel-footer-exit {
.fa-times {
&:before {
content: '\f053';
}
}
.eicon-close {
&:before {
content: '\E87E';
}
}
}
#elementor-panel-footer-settings {
.fa-cog {
&:before {
content: '\f053';
}
}
.eicon-cog {
&:before {
content: '\E87E';
}
}
}
#elementor-panel-saver-menu-save-draft,
#elementor-panel-saver-menu-discard {
display: none !important;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

View File

@@ -0,0 +1,683 @@
( function( $ ) {
'use strict';
var JetMenu = function( element, options ) {
this.defaultSettings = {
enabled: false,
threshold: 767, // Minimal menu width, when this plugin activates
mouseLeaveDelay: 500,
openSubType: 'click', // hover, click
megaWidthType: 'container',
megaWidthSelector: '',
mainMenuSelector: '.jet-menu',
menuItemSelector: '.jet-menu-item',
moreMenuContent: '&middot;&middot;&middot;',
templates: {
mobileMenuToogleButton: '<button class="jet-mobile-menu-toggle-button"><i class="jet-menu-toggle__icon"></i></button>',
}
}
this.settings = $.extend( this.defaultSettings, options );
this.$window = $( window );
this.$document = $( document );
this.$element = $( element );
this.$instance = $( this.settings.mainMenuSelector, this.$element ).addClass( 'jet-responsive-menu' );
this.$menuItems = $( '>' + this.settings.menuItemSelector, this.$instance ).addClass( 'jet-responsive-menu-item' );
this.$moreItemsInstance = null;
this.hiddenItemsArray = [];
this.$mobileStateCover = null;
this.createMenuInstance();
this.$instance.trigger( 'jetMenuCreated' );
}
JetMenu.prototype = {
constructor: JetMenu,
createMenuInstance: function() {
var self = this,
mainMenuWidth,
totalVisibleItemsWidth = 0;
this.subMenuRebuild();
this.subMegaMenuRebuild();
// Add mobile menu cover
$( 'body' ).append( '<div class="jet-mobile-menu-cover"></div>' );
this.$mobileStateCover = $( '.jet-mobile-menu-cover' );
// Add available items list
if ( ! tools.isEmpty( this.settings.moreMenuContent ) && self.settings.enabled ) {
self.$instance.append( '<li class="jet-menu-item jet-menu-item-has-children jet-simple-menu-item jet-responsive-menu-available-items" hidden><a href="#" class="top-level-link"><div class="jet-menu-item-wrapper">' + this.settings.moreMenuContent + '</div></a><ul class="jet-sub-menu"></ul></li>' );
self.$moreItemsInstance = $( '> .jet-responsive-menu-available-items', this.$instance );
self.$moreItemsInstance.attr( { 'hidden': 'hidden' } );
}
// Add mobile menu toogle button
if ( ! tools.isEmpty( this.settings.templates.mobileMenuToogleButton ) ) {
this.$element.prepend( this.settings.templates.mobileMenuToogleButton );
this.$mobileToogleButton = $( '.jet-mobile-menu-toggle-button', this.$element );
}
if ( this.isThreshold() ) {
this.$element.addClass( 'jet-mobile-menu' );
$( 'body' ).addClass( 'jet-mobile-menu-active' );
} else {
$( 'body' ).addClass( 'jet-desktop-menu-active' );
this.rebuildItems();
this.$instance.trigger( 'rebuildItems' ); // subMenu position rebuild
}
this.subMenuHandler();
this.mobileViewHandler();
this.watch();
},
/**
* SubMenu items Handler.
*
* @return {void}
*/
subMenuHandler: function() {
var self = this,
transitionend = 'transitionend oTransitionEnd webkitTransitionEnd',
prevClickedItem = null,
menuItem,
menuItemParents,
timer;
if ( self.mobileAndTabletcheck() ) {
this.$instance.on( 'touchstart', '.jet-menu-item > a, .jet-menu-item > a .jet-dropdown-arrow', touchStartItem );
this.$instance.on( 'touchend', '.jet-menu-item > a, .jet-menu-item > a .jet-dropdown-arrow', touchEndItem );
} else {
switch ( this.settings.openSubType ) {
case 'hover':
this.$instance.on( 'mouseenter', '.jet-menu-item > a', mouseEnterHandler );
this.$instance.on( 'mouseleave', '.jet-menu-item > a', mouseLeaveHandler );
break;
case 'click':
this.$instance.on( 'click', '.jet-menu-item > a', clickHandler );
break;
}
this.$instance.on( 'mouseenter', '.jet-sub-menu, .jet-sub-mega-menu', mouseEnterSubMenuHandler );
this.$instance.on( 'mouseenter', mouseEnterInstanceHandler );
this.$instance.on( 'mouseleave', mouseLeaveInstanceHandler );
}
function touchStartItem( event ) {
var $currentTarget = $( event.currentTarget ),
$this = $currentTarget.closest('.jet-menu-item');
$this.data( 'offset', $this.offset().top );
}
function touchEndItem( event ) {
var $this,
$siblingsItems,
$link,
linkHref,
$currentTarget,
subMenu,
offset;
event.preventDefault();
event.stopPropagation();
$currentTarget = $( event.currentTarget );
$this = $currentTarget.closest('.jet-menu-item');
$siblingsItems = $this.siblings( '.jet-menu-item.jet-menu-item-has-children' );
$link = $( '> a', $this );
linkHref = $link.attr( 'href' );
subMenu = $( '.jet-sub-menu:first, .jet-sub-mega-menu', $this );
offset = $this.data( 'offset' );
if ( offset !== $this.offset().top ) {
return false;
}
if ( $currentTarget.hasClass( 'jet-dropdown-arrow' ) ) {
if ( !subMenu[0] ) {
return false;
}
if ( ! $this.hasClass( 'jet-menu-hover' ) ) {
$this.addClass( 'jet-menu-hover' );
$siblingsItems.removeClass( 'jet-menu-hover' );
$( '.jet-menu-item-has-children', $siblingsItems ).removeClass( 'jet-menu-hover' );
} else {
$this.removeClass( 'jet-menu-hover' );
$( '.jet-menu-item-has-children', $this ).removeClass( 'jet-menu-hover' );
}
}
if ( $currentTarget.hasClass( 'top-level-link' ) || $currentTarget.hasClass( 'sub-level-link' ) ) {
if ( '#' === linkHref ) {
if ( ! $this.hasClass( 'jet-menu-hover' ) ) {
$this.addClass( 'jet-menu-hover' );
$siblingsItems.removeClass( 'jet-menu-hover' );
$( '.jet-menu-item-has-children', $siblingsItems ).removeClass( 'jet-menu-hover' );
} else {
$this.removeClass( 'jet-menu-hover' );
$( '.jet-menu-item-has-children', $this ).removeClass( 'jet-menu-hover' );
}
return false;
} else {
window.location = linkHref;
$( 'body' ).removeClass( 'jet-mobile-menu-visible' );
self.$element.removeClass( 'jet-mobile-menu-active-state' );
return false;
}
}
}
function clickHandler( event ) {
var $this,
$siblingsItems,
$link,
$currentTarget,
subMenu;
event.preventDefault();
event.stopPropagation();
$currentTarget = $( event.currentTarget );
$this = $currentTarget.closest('.jet-menu-item');
$siblingsItems = $this.siblings( '.jet-menu-item.jet-menu-item-has-children' );
$link = $( '> a', $this );
subMenu = $( '.jet-sub-menu:first, .jet-sub-mega-menu', $this );
if ( $siblingsItems[0] ) {
$siblingsItems.removeClass( 'jet-menu-hover' );
$( 'jet-menu-item-has-children', $siblingsItems ).removeClass( 'jet-menu-hover' );
}
if ( ! $( '.jet-sub-menu, .jet-sub-mega-menu', $this )[0] || $this.hasClass('jet-menu-hover') ) {
window.location = $link.attr( 'href' );
$( 'body' ).removeClass( 'jet-mobile-menu-visible' );
self.$element.removeClass( 'jet-mobile-menu-active-state' );
return false;
}
if ( subMenu[0] ) {
$this.addClass( 'jet-menu-hover' );
}
}
function mouseEnterHandler( event ) {
var subMenu;
menuItem = $( event.target ).parents( '.jet-menu-item' );
subMenu = menuItem.children( '.jet-sub-menu, .jet-sub-mega-menu' ).first();
$( '.jet-menu-hover', this.$instance ).removeClass( 'jet-menu-hover' );
if ( subMenu[0] ) {
menuItem.addClass( 'jet-menu-hover' );
}
}
function mouseLeaveHandler( event ) {
// Item Mouse Leave Event
}
function mouseEnterSubMenuHandler( event ) {
clearTimeout( timer );
}
function mouseEnterInstanceHandler( event ) {
clearTimeout( timer );
}
function mouseLeaveInstanceHandler( event ) {
timer = setTimeout( function() {
$( '.jet-menu-hover', this.$instance ).removeClass( 'jet-menu-hover' );
}, self.settings.mouseLeaveDelay );
}
var windowWidth = $( window ).width();
self.$window.on( 'orientationchange resize', function( event ) {
if ( $( 'body' ).hasClass( 'jet-mobile-menu-active' ) ) {
return;
}
// Do not trigger a change if the viewport hasn't actually changed. Scrolling on iOS will trigger a resize.
if ( $( window ).width() === windowWidth ) {
return;
}
windowWidth = $( window ).width();
self.$instance.find( '.jet-menu-item' ).removeClass( 'jet-menu-hover' );
} );
self.$document.on( 'touchend', function( event ) {
if ( $( 'body' ).hasClass( 'jet-mobile-menu-active' ) ) {
return;
}
if ( $( event.target ).closest( '.jet-menu-item' ).length ) {
return;
}
self.$instance.find( '.jet-menu-item' ).removeClass( 'jet-menu-hover' );
} );
},
/**
* Mobile View Handler.
*
* @return {void}
*/
mobileViewHandler: function() {
var self = this,
toogleStartEvent = 'mousedown',
toogleEndEvent = 'mouseup';
if ( 'ontouchend' in window || 'ontouchstart' in window ) {
toogleStartEvent = 'touchstart';
toogleEndEvent = 'touchend';
}
this.$mobileToogleButton.on( toogleEndEvent, function( event ) {
event.preventDefault();
$( 'body' ).toggleClass( 'jet-mobile-menu-visible' );
self.$element.toggleClass( 'jet-mobile-menu-active-state' );
} );
this.$document.on( toogleEndEvent, function( event ) {
if ( $( event.target ).closest( self.$element ).length ) {
return;
}
if ( ! self.$element.hasClass( 'jet-mobile-menu' ) || ! self.$element.hasClass( 'jet-mobile-menu-active-state' ) ) {
return;
}
$( 'body' ).removeClass( 'jet-mobile-menu-visible' );
self.$element.removeClass( 'jet-mobile-menu-active-state' );
} );
},
/**
* Responsive menu watcher function.
*
* @param {number} Watcher debounce delay.
* @return {void}
*/
watch: function( delay ) {
var delay = delay || 10;
$( window ).on( 'resize.jetResponsiveMenu orientationchange.jetResponsiveMenu', this.debounce( delay, this.watcher.bind( this ) ) );
this.$instance.trigger( 'containerResize' );
},
/**
* Responsive menu watcher callback.
*
* @param {Object} Resize or Orientationchange event.
* @return {void}
*/
watcher: function( event ) {
if ( this.isThreshold() ) {
this.$element.addClass( 'jet-mobile-menu' );
$( 'body' ).addClass( 'jet-mobile-menu-active' );
$( 'body' ).removeClass( 'jet-desktop-menu-active' );
this.$menuItems.removeAttr( 'hidden' );
// More-items listing not empty checking
if ( 0 !== this.hiddenItemsArray.length ) {
$( '> .jet-sub-menu', this.$moreItemsInstance ).empty();
}
if ( this.settings.enabled ) {
this.$moreItemsInstance.attr( { 'hidden': 'hidden' } );
}
} else {
this.$element.removeClass( 'jet-mobile-menu' );
$( 'body' ).removeClass( 'jet-mobile-menu-active' );
$( 'body' ).addClass( 'jet-desktop-menu-active' );
$( 'body' ).removeClass( 'jet-mobile-menu-visible' );
this.rebuildItems();
this.$instance.trigger( 'rebuildItems' ); // subMenu position rebuild
this.$instance.trigger( 'containerResize' );
}
},
/**
* Responsive Menu rebuilding function.
*
* @return {void}
*/
rebuildItems: function() {
if ( ! this.settings.enabled ) {
return false;
}
var self = this,
mainMenuWidth = this.$instance.width(),
correctedMenuWidth = this.$instance.width() - self.$moreItemsInstance.outerWidth( true ),
iterationVisibleItemsWidth = 0,
iterationHiddenItemsWidth = this.getVisibleItemsWidth(),
visibleItemsArray = [],
hiddenItemsArray = [];
self.$menuItems.each( function() {
var $this = $( this );
iterationVisibleItemsWidth += $this.outerWidth( true );
if ( iterationVisibleItemsWidth > correctedMenuWidth && ! tools.inArray( this, hiddenItemsArray ) ) {
hiddenItemsArray.push( this );
} else {
visibleItemsArray.push( this );
}
} );
hiddenItemsArray.forEach( function( item ) {
var $item = $( item );
$item.attr( { 'hidden': 'hidden' } );
} );
visibleItemsArray.forEach( function( item, index ) {
var $item = $( item );
$item.removeAttr( 'hidden' );
} );
$( '> .jet-sub-menu', self.$moreItemsInstance ).empty();
hiddenItemsArray.forEach( function( item ) {
var $clone = $( item ).clone();
// Remove sub-mega-menu content
$( '.jet-sub-mega-menu', $clone ).remove();
$clone.addClass( 'jet-sub-menu-item' );
$clone.removeAttr( 'hidden' );
$( '> .top-level-link', $clone ).toggleClass( 'top-level-link sub-level-link' );
$( '> .jet-sub-menu', self.$moreItemsInstance ).append( $clone );
} );
if ( 0 == hiddenItemsArray.length ) {
self.$moreItemsInstance.attr( { 'hidden': 'hidden' } );
self.$moreItemsInstance.addClass( 'jet-empty' );
} else {
self.$moreItemsInstance.removeAttr( 'hidden' );
self.$moreItemsInstance.removeClass( 'jet-empty' );
}
self.hiddenItemsArray = hiddenItemsArray;
//this.$instance.trigger( 'rebuildItems' ); // when `Menu rollUp` is disabled `rebuildItems`(subMenu position rebuild) trigger does not work
},
/**
* Sub Menu rebuilding function.
*
* @return {void}
*/
subMenuRebuild: function() {
var self = this,
initSubMenuPosition = false;
this.$instance.on( 'rebuildItems', function() {
var $subMenuList = $( '.jet-sub-menu', self.$instance ),
maxWidth = self.$window.outerWidth( true ),
isRTL = $( 'body' ).hasClass( 'rtl' );
if ( ! $subMenuList[0] ) {
return;
}
if ( initSubMenuPosition ) {
$subMenuList.removeClass( 'inverse-side' );
initSubMenuPosition = false;
}
$subMenuList.each( function() {
var $this = $( this ),
subMenuOffset = $this.offset().left,
subMenuPos = subMenuOffset + $this.outerWidth( true );
if ( ! isRTL ) {
if ( subMenuPos >= maxWidth ) {
$this.addClass( 'inverse-side' );
$this.find( '.jet-sub-menu' ).addClass( 'inverse-side' );
initSubMenuPosition = true;
} else if ( subMenuOffset < 0 ) {
$this.removeClass( 'inverse-side' );
$this.find( '.jet-sub-menu' ).removeClass( 'inverse-side' );
}
} else {
if ( subMenuOffset < 0 ) {
$this.addClass( 'inverse-side' );
$this.find( '.jet-sub-menu' ).addClass( 'inverse-side' );
initSubMenuPosition = true;
} else if ( subMenuPos >= maxWidth ) {
$this.removeClass( 'inverse-side' );
$this.find( '.jet-sub-menu' ).removeClass( 'inverse-side' );
}
}
} );
} );
},
/**
* Sub Mega Menu rebuilding function.
*
* @return {void}
*/
subMegaMenuRebuild: function() {
var self = this;
this.$instance.on( 'containerResize', function() {
var $megaMenuList = $( '.jet-sub-mega-menu', self.$instance ),
maxWidth = $( 'body' ).outerWidth( true );
switch( self.settings.megaWidthType ) {
case 'items':
var visibleItemsWidth = self.getVisibleItemsWidth(),
firstOffset = $( '> .jet-menu-item:first', self.$instance ).position().left;
$megaMenuList.css( {
'width': visibleItemsWidth + 'px',
'left': firstOffset
} );
break;
case 'selector':
var customSelector = $( self.settings.megaWidthSelector ),
instanceOffset = null,
customSelectorOffset = null;
if ( customSelector[0] ) {
instanceOffset = self.$instance.offset().left;
customSelectorOffset = customSelector.offset().left;
$megaMenuList.css( {
'width': customSelector.outerWidth(),
'left': (customSelectorOffset - instanceOffset ) + 'px'
} );
}
break;
}
if ( $megaMenuList[0] ) {
$megaMenuList.css( {
'maxWidth': ''
} );
$megaMenuList.each( function() {
var $this = $( this ),
megaMenuOffsetLeft = $this.offset().left,
megaMenuOffsetRight = megaMenuOffsetLeft + $this.outerWidth( true );
if ( megaMenuOffsetRight >= maxWidth ) {
$this.css( {
'maxWidth': maxWidth - megaMenuOffsetLeft
} );
}
} );
}
} );
},
/**
* Get visible items total width
*
* @return {int}
*/
getVisibleItemsWidth: function() {
var totalVisibleItemsWidth = 0;
this.$menuItems.each( function() {
var $this = $( this );
if ( ! $this.hasAttr( 'hidden' ) ) {
totalVisibleItemsWidth += $this.outerWidth( true );
}
} );
return totalVisibleItemsWidth;
},
/**
* Get mobile status.
*
* @return {boolean} Mobile Status
*/
isThreshold: function() {
return ( this.$window.width() < this.settings.threshold ) ? true : false;
},
/**
* Mobile and tablet check funcion.
*
* @return {boolean} Mobile Status
*/
mobileAndTabletcheck: function() {
var check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
return check;
},
/**
* Debounce the function call
*
* @param {number} threshold The delay.
* @param {Function} callback The function.
*/
debounce: function ( threshold, callback ) {
var timeout;
return function debounced( $event ) {
function delayed() {
callback.call( this, $event );
timeout = null;
}
if ( timeout ) {
clearTimeout( timeout );
}
timeout = setTimeout( delayed, threshold );
};
}
}
/*
* Js tools
*/
var tools = {
isEmpty: function( value ) {
return ( ( false === value ) || ( '' === value ) || ( null === value ) || ( undefined === value ));
},
isEmptyObject: function( value ) {
return ( true === this.isEmpty( value ) ) || ( 0 === value.length );
},
isString: function(value) {
return ( ( 'string' === typeof value ) || ( value instanceof String ) );
},
isArray: function( value ) {
return $.isArray( value );
},
inArray: function( value, array ) {
return ( $.inArray( value, array ) !== -1);
}
};
/*
* Jq tools
*/
$.fn.hasAttr = function( name ) {
return this.attr( name ) !== undefined;
};
// jQuery plugin
$.fn.JetMenu = function( options ) {
return this.each( function() {
var $this = $( this ),
pluginOptions = ( 'object' === typeof options ) ? options : {};
if ( ! $this.data( 'JetMenu' ) ) {
// create plugin instance (only if not exists) and expose the entire instance API
$this.data( 'JetMenu', new JetMenu( this, pluginOptions ) );
}
} );
};
}( jQuery ) );

View File

@@ -0,0 +1,38 @@
(function( $ ){
'use strict';
var jetMenu = {
init: function() {
var rollUp = false,
jetMenuMouseleaveDelay = 500,
jetMenuMegaWidthType = 'container',
jetMenuMegaWidthSelector = '',
jetMenuMegaOpenSubType = 'hover',
jetMenuMobileBreakpoint = 768;
if ( window.jetMenuPublicSettings && window.jetMenuPublicSettings.menuSettings ) {
rollUp = ( 'true' === jetMenuPublicSettings.menuSettings.jetMenuRollUp ) ? true : false;
jetMenuMouseleaveDelay = jetMenuPublicSettings.menuSettings.jetMenuMouseleaveDelay || 500;
jetMenuMegaWidthType = jetMenuPublicSettings.menuSettings.jetMenuMegaWidthType || 'container';
jetMenuMegaWidthSelector = jetMenuPublicSettings.menuSettings.jetMenuMegaWidthSelector || '';
jetMenuMegaOpenSubType = jetMenuPublicSettings.menuSettings.jetMenuMegaOpenSubType || 'hover';
jetMenuMobileBreakpoint = jetMenuPublicSettings.menuSettings.jetMenuMobileBreakpoint || 768;
}
$( '.jet-menu-container' ).JetMenu( {
enabled: rollUp,
mouseLeaveDelay: +jetMenuMouseleaveDelay,
megaWidthType: jetMenuMegaWidthType,
megaWidthSelector: jetMenuMegaWidthSelector,
openSubType: jetMenuMegaOpenSubType,
threshold: +jetMenuMobileBreakpoint
} );
},
};
jetMenu.init();
}( jQuery ));

View File

@@ -0,0 +1,271 @@
( function( $, elementor ) {
"use strict";
var JetMenuWidget = {
init: function() {
var widgets = {
'jet-mega-menu.default' : JetMenuWidget.widgetMegaMenu,
'jet-custom-menu.default' : JetMenuWidget.widgetCustomMenu
};
$.each( widgets, function( widget, callback ) {
elementor.hooks.addAction( 'frontend/element_ready/' + widget, callback );
});
},
widgetMegaMenu: function( $scope ) {
var $target = $scope.find( '.jet-menu-container' ),
rollUp = false,
jetMenuMouseleaveDelay = 500,
jetMenuMegaWidthType = 'container',
jetMenuMegaWidthSelector = '',
jetMenuMegaOpenSubType = 'hover',
jetMenuMobileBreakpoint = 768;
if ( window.jetMenuPublicSettings && window.jetMenuPublicSettings.menuSettings ) {
rollUp = ( 'true' === jetMenuPublicSettings.menuSettings.jetMenuRollUp ) ? true : false;
jetMenuMouseleaveDelay = jetMenuPublicSettings.menuSettings.jetMenuMouseleaveDelay || 500;
jetMenuMegaWidthType = jetMenuPublicSettings.menuSettings.jetMenuMegaWidthType || 'container';
jetMenuMegaWidthSelector = jetMenuPublicSettings.menuSettings.jetMenuMegaWidthSelector || '';
jetMenuMegaOpenSubType = jetMenuPublicSettings.menuSettings.jetMenuMegaOpenSubType || 'hover';
jetMenuMobileBreakpoint = jetMenuPublicSettings.menuSettings.jetMenuMobileBreakpoint || 768;
}
$target.JetMenu( {
enabled: rollUp,
mouseLeaveDelay: +jetMenuMouseleaveDelay,
megaWidthType: jetMenuMegaWidthType,
megaWidthSelector: jetMenuMegaWidthSelector,
openSubType: jetMenuMegaOpenSubType,
threshold: +jetMenuMobileBreakpoint
} );
},
widgetCustomMenu: function( $scope ) {
var $target = $scope.find( '.jet-custom-nav' ),
instance = null,
menuItem = null;
if ( ! $target.length ) {
return;
}
if ( JetMenuWidget.mobileAndTabletcheck() ) {
$scope.on( 'touchstart', '.jet-custom-nav__item > a, .jet-custom-nav__item > a .jet-dropdown-arrow', touchStartItem );
$scope.on( 'touchend', '.jet-custom-nav__item > a, .jet-custom-nav__item > a .jet-dropdown-arrow', touchEndItem );
} else {
$scope.on( 'mouseenter mouseover', '.jet-custom-nav__item', mouseEnterHandler );
$scope.on( 'mouseleave', '.jet-custom-nav__item', mouseLeaveHandler );
}
function mouseEnterHandler( event ) {
menuItem = $( event.target ).parents( '.jet-custom-nav__item' );
menuItem.addClass( 'hover-state' );
}
function mouseLeaveHandler( event ) {
menuItem = $( event.target ).parents( '.jet-custom-nav__item' );
menuItem.removeClass( 'hover-state' );
}
function touchStartItem( event ) {
var $this = $( event.currentTarget ).closest( '.jet-custom-nav__item' );
$this.data( 'offset', $this.offset().top );
$this.data( 'windowOffset', $( window ).scrollTop() );
}
function touchEndItem( event ) {
var $currentTarget,
$this,
$siblingsItems,
$link,
linkHref,
subMenu,
offset,
windowOffset;
event.preventDefault();
event.stopPropagation();
$currentTarget = $( event.currentTarget );
$this = $currentTarget.closest( '.jet-custom-nav__item' );
$siblingsItems = $this.siblings( '.jet-custom-nav__item.menu-item-has-children' );
$link = $( '> a', $this );
linkHref = $link.attr( 'href' );
subMenu = $( '.jet-custom-nav__sub:first, .jet-custom-nav__mega-sub:first', $this );
offset = $this.data( 'offset' );
windowOffset = $this.data( 'windowOffset' );
if ( offset !== $this.offset().top || windowOffset !== $( window ).scrollTop() ) {
return false;
}
if ( $currentTarget.hasClass( 'jet-dropdown-arrow' ) ) {
if ( !subMenu[0] ) {
return false;
}
if ( ! $this.hasClass( 'hover-state' ) ) {
$this.addClass( 'hover-state' );
$siblingsItems.removeClass( 'hover-state' );
$( '.jet-custom-nav__item.menu-item-has-children', $siblingsItems ).removeClass( 'hover-state' );
} else {
$this.removeClass( 'hover-state' );
$( '.jet-custom-nav__item.menu-item-has-children', $this ).removeClass( 'hover-state' );
}
}
if ( $currentTarget.hasClass( 'jet-custom-nav__item-link' ) ) {
if ( '#' === linkHref ) {
if ( ! $this.hasClass( 'hover-state' ) ) {
$this.addClass( 'hover-state' );
$siblingsItems.removeClass( 'hover-state' );
$( '.jet-custom-nav__item.menu-item-has-children', $siblingsItems ).removeClass( 'hover-state' );
} else {
$this.removeClass( 'hover-state' );
$( '.jet-custom-nav__item.menu-item-has-children', $this ).removeClass( 'hover-state' );
}
} else {
window.location = linkHref;
return false;
}
}
}
var initSubMenuPosition = false;
function setSubMenuPosition(){
if ( initSubMenuPosition ) {
$target.find( '.jet-custom-nav__sub.inverse-side' ).removeClass( 'inverse-side' );
initSubMenuPosition = false;
}
var subMenu = $( '.jet-custom-nav__sub', $target ),
$body = $( 'body' ),
maxWidth = $body.outerWidth( true ),
isMobile = 'mobile' === elementor.getCurrentDeviceMode();
if ( isMobile ) {
return;
}
if ( subMenu[0] ) {
subMenu.each( function() {
var $this = $( this ),
subMenuOffsetLeft = $this.offset().left,
subMenuOffsetRight = subMenuOffsetLeft + $this.outerWidth( true ),
subMenuPosition = $this.closest( '.jet-custom-nav' ).hasClass( 'jet-custom-nav--dropdown-left-side' ) ? 'left-side' : 'right-side';
if ( 'right-side' === subMenuPosition ) {
if ( subMenuOffsetRight >= maxWidth ) {
$this.addClass( 'inverse-side' );
$this.find( '.jet-custom-nav__sub' ).addClass( 'inverse-side' );
initSubMenuPosition = true;
} else if ( subMenuOffsetLeft < 0 ) {
$this.removeClass( 'inverse-side' );
$this.find( '.jet-custom-nav__sub' ).removeClass( 'inverse-side' );
}
} else {
if ( subMenuOffsetLeft < 0 ) {
$this.addClass( 'inverse-side' );
$this.find( '.jet-custom-nav__sub' ).addClass( 'inverse-side' );
initSubMenuPosition = true;
} else if ( subMenuOffsetRight >= maxWidth ) {
$this.removeClass( 'inverse-side' );
$this.find( '.jet-custom-nav__sub' ).removeClass( 'inverse-side' );
}
}
} );
}
}
setSubMenuPosition();
$( window ).on( 'resize.JetCustomMenu orientationchange.JetCustomMenu', setSubMenuPosition );
var initMaxMegaMenuWidth = false;
function setMaxMegaMenuWidth(){
var megaMenu = $( '.jet-custom-nav__mega-sub', $target ),
$body = $( 'body' ),
maxWidth = $body.outerWidth( true ),
isMobile = 'mobile' === elementor.getCurrentDeviceMode();
if ( initMaxMegaMenuWidth ) {
megaMenu.css( {
'maxWidth': ''
} );
initMaxMegaMenuWidth = false;
}
if ( isMobile ) {
return;
}
if ( megaMenu[0] ) {
megaMenu.each( function() {
var $this = $( this ),
megaMenuTranslateX = $this.css( 'transform' ).replace( /,/g, "" ).split( " " )[4] || 0,
megaMenuOffsetLeft = $this.offset().left - megaMenuTranslateX,
megaMenuOffsetRight = megaMenuOffsetLeft + $this.outerWidth( true ),
megaMenuPosition = $this.closest( '.jet-custom-nav' ).hasClass( 'jet-custom-nav--dropdown-left-side' ) ? 'left-side' : 'right-side';
if ( 'right-side' === megaMenuPosition ) {
if ( megaMenuOffsetRight >= maxWidth ) {
$this.css({
'maxWidth': maxWidth - megaMenuOffsetLeft - 10
});
initMaxMegaMenuWidth = true;
}
} else {
if ( megaMenuOffsetLeft < 0 ) {
$this.css({
'maxWidth': megaMenuOffsetRight - 10
});
initMaxMegaMenuWidth = true;
}
}
} );
}
}
setMaxMegaMenuWidth();
$( window ).on( 'resize.JetCustomMenu orientationchange.JetCustomMenu', setMaxMegaMenuWidth );
},
/**
* Mobile and tablet check funcion.
*
* @return {boolean} Mobile Status
*/
mobileAndTabletcheck: function() {
var check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
return check;
}
};
$( window ).on( 'elementor/frontend/init', JetMenuWidget.init );
}( jQuery, window.elementorFrontend ) );

View File

@@ -0,0 +1,309 @@
@font-face {
font-family: 'jetmenu';
src: url('../fonts/jetmenu.eot?nc756v');
src: url('../fonts/jetmenu.eot?nc756v#iefix') format('embedded-opentype'),
url('../fonts/jetmenu.ttf?nc756v') format('truetype'),
url('../fonts/jetmenu.woff?nc756v') format('woff'),
url('../fonts/jetmenu.svg?nc756v#jetmenu') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="jetmenu-icon-"], [class*=" jetmenu-icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'jetmenu' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
height: 38px;
display: block;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
[class^="jetmenu-icon-"]:before, [class*=" jetmenu-icon-"]:before {
font-size: 58px;
display: block;
margin-top: -10px;
}
.jetmenu-icon-01:before {
content: "\e900";
}
.jetmenu-icon-02:before {
content: "\e901";
}
.jetmenu-icon-03:before {
content: "\e902";
}
.jetmenu-icon-04:before {
content: "\e903";
}
.jetmenu-icon-05:before {
content: "\e904";
}
.jetmenu-icon-06:before {
content: "\e905";
}
.jetmenu-icon-07:before {
content: "\e906";
}
.jetmenu-icon-08:before {
content: "\e907";
}
.jetmenu-icon-09:before {
content: "\e908";
}
.jetmenu-icon-10:before {
content: "\e909";
}
.jetmenu-icon-11:before {
content: "\e90a";
}
.jetmenu-icon-12:before {
content: "\e90b";
}
.jetmenu-icon-13:before {
content: "\e90c";
}
.jetmenu-icon-14:before {
content: "\e90d";
}
.jetmenu-icon-15:before {
content: "\e90e";
}
.jetmenu-icon-16:before {
content: "\e90f";
}
.jetmenu-icon-17:before {
content: "\e910";
}
.jetmenu-icon-18:before {
content: "\e911";
}
.jetmenu-icon-19:before {
content: "\e912";
}
.jetmenu-icon-20:before {
content: "\e913";
}
.jetmenu-icon-21:before {
content: "\e914";
}
.jetmenu-icon-22:before {
content: "\e915";
}
.jetmenu-icon-23:before {
content: "\e916";
}
.jetmenu-icon-24:before {
content: "\e917";
}
.jetmenu-icon-25:before {
content: "\e918";
}
.jetmenu-icon-26:before {
content: "\e919";
}
.jetmenu-icon-27:before {
content: "\e91a";
}
.jetmenu-icon-28:before {
content: "\e91b";
}
.jetmenu-icon-29:before {
content: "\e91c";
}
.jetmenu-icon-30:before {
content: "\e91d";
}
.jetmenu-icon-31:before {
content: "\e91e";
}
.jetmenu-icon-32:before {
content: "\e91f";
}
.jetmenu-icon-33:before {
content: "\e920";
}
.jetmenu-icon-34:before {
content: "\e921";
}
.jetmenu-icon-35:before {
content: "\e922";
}
.jetmenu-icon-36:before {
content: "\e923";
}
.jetmenu-icon-37:before {
content: "\e924";
}
.jetmenu-icon-38:before {
content: "\e925";
}
.jetmenu-icon-39:before {
content: "\e926";
}
.jetmenu-icon-40:before {
content: "\e927";
}
.jetmenu-icon-41:before {
content: "\e928";
}
.jetmenu-icon-42:before {
content: "\e929";
}
.jetmenu-icon-43:before {
content: "\e92a";
}
.jetmenu-icon-44:before {
content: "\e92b";
}
.jetmenu-icon-45:before {
content: "\e92c";
}
.jetmenu-icon-46:before {
content: "\e92d";
}
.jetmenu-icon-47:before {
content: "\e92e";
}
.jetmenu-icon-48:before {
content: "\e92f";
}
.jetmenu-icon-49:before {
content: "\e930";
}
.jetmenu-icon-50:before {
content: "\e931";
}
.jetmenu-icon-51:before {
content: "\e932";
}
.jetmenu-icon-52:before {
content: "\e933";
}
.jetmenu-icon-53:before {
content: "\e934";
}
.jetmenu-icon-54:before {
content: "\e935";
}
.jetmenu-icon-55:before {
content: "\e936";
}
.jetmenu-icon-56:before {
content: "\e937";
}
.jetmenu-icon-57:before {
content: "\e938";
}
.jetmenu-icon-58:before {
content: "\e939";
}
.jetmenu-icon-59:before {
content: "\e93a";
}
.jetmenu-icon-60:before {
content: "\e93b";
}
.jetmenu-icon-61:before {
content: "\e93c";
}
.jetmenu-icon-62:before {
content: "\e93d";
}
.jetmenu-icon-63:before {
content: "\e93e";
}
.jetmenu-icon-64:before {
content: "\e93f";
}
.jetmenu-icon-65:before {
content: "\e940";
}
.jetmenu-icon-66:before {
content: "\e941";
}
.jetmenu-icon-67:before {
content: "\e942";
}
.jetmenu-icon-68:before {
content: "\e943";
}
.jetmenu-icon-69:before {
content: "\e944";
}
.jetmenu-icon-70:before {
content: "\e945";
}
.jetmenu-icon-71:before {
content: "\e946";
}
.jetmenu-icon-73:before {
content: "\e94f";
}
.jetmenu-icon-72:before {
content: "\e947";
}
.jetmenu-icon-662:before {
content: "\e948";
}
.jetmenu-icon-672:before {
content: "\e949";
}
.jetmenu-icon-682:before {
content: "\e94a";
}
.jetmenu-icon-692:before {
content: "\e94b";
}
.jetmenu-icon-702:before {
content: "\e94c";
}
.jetmenu-icon-712:before {
content: "\e94d";
}
.jetmenu-icon-722:before {
content: "\e94e";
}
.jetmenu-icon-81:before {
content: "\e950";
}
.jetmenu-icon-82:before {
content: "\e951";
}
.jetmenu-icon-86:before {
content: "\e952";
}
.jetmenu-icon-87:before {
content: "\e953";
}
.jetmenu-icon-88:before {
content: "\e954";
}
.jetmenu-icon-89:before {
content: "\e955";
}
.jetmenu-icon-90:before {
content: "\e956";
}
.jetmenu-icon-91:before {
content: "\e957";
}
.jetmenu-icon-92:before {
content: "\e958";
}
.jetmenu-icon-93:before {
content: "\e959";
}
.jetmenu-icon-94:before {
content: "\e95a";
}
.jetmenu-icon-95:before {
content: "\e95b";
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 183 KiB

View File

@@ -0,0 +1,684 @@
@import "widgets/jet-custom-menu";
@mixin font-awesome-icon {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.jet-menu-container {
position: relative;
width: 100%;
}
.jet-menu {
width: 100%;
position: relative;
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-flow: column wrap;
justify-content: center;
align-items: stretch;
@media (min-width: 768px) {
flex-flow: row wrap;
}
.jet-mobile-menu-active & {
flex-flow: column wrap;
}
.jet-desktop-menu-active & {
flex-flow: row wrap;
}
> .jet-menu-item {
display: flex;
> a {
width: 100%;
margin: 0;
//white-space: nowrap;
padding: 10px;
}
}
ul {
left: 0;
}
}
.jet-menu-item {
position: relative;
> a {
display: block;
text-decoration: none;
width: auto;
}
&.jet-mega-menu-item {
position: static;
&.jet-mega-menu-position-relative-item {
position: relative;
}
}
.top-level-link {
display: flex;
}
&-desc {
white-space: normal;
}
.jet-sub-menu {
display: block;
min-width: 200px;
margin: 0;
background-color: white;
list-style: none;
left: 0;
top: 0;
position: relative;
padding: 0;
z-index: auto;
.rtl & {
left: auto;
right: 0;
}
@media (min-width: 768px) {
position: absolute;
}
.jet-mobile-menu-active & {
position: relative;
}
.jet-desktop-menu-active & {
position: absolute;
top: 100%;
left: 0;
right: auto;
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.2 );
z-index: 999;
pointer-events: none;
&.inverse-side {
right: 0;
left: auto;
}
.jet-sub-menu {
top: 0;
left: 100%;
right: auto;
&.inverse-side {
right: 100%;
left: auto;
}
}
}
.jet-desktop-menu-active.rtl & {
left: auto;
right: 0;
&.inverse-side {
right: auto;
left: 0;
}
.jet-sub-menu {
left: auto;
right: 100%;
&.inverse-side {
right: auto;
left: 100%;
}
}
}
> li {
display: block;
> a {
padding: 10px;
}
}
}
}
.jet-menu-item-wrapper {
display: flex;
flex-wrap: wrap;
align-items: center;
.jet-menu-icon {
align-self: center;
margin-right: 10px;
.label-hidden & {
margin-right: 0;
margin-left: 0;
}
}
.jet-dropdown-arrow {
align-self: center;
margin-left: 10px;
}
.jet-menu-badge {
display: none;
align-self: flex-start;
text-align: center;
width: 0;
&.jet-hide-mobile {
.jet-mobile-menu-active & {
.jet-menu-badge__inner {
display: none;
}
}
}
&__inner {
display: inline-block;
}
}
}
.jet-menu-inner {
@media ( max-width: 767px ) {
display: none;
}
.jet-desktop-menu-active & {
display: block;
}
}
.jet-mobile-menu-active {
.jet-mobile-menu-toggle-button {
display: block;
}
.jet-menu {
background-image: none;
}
.jet-menu-container.jet-mobile-menu {
position: fixed;
top: 0;
right: -80%;
z-index: 998;
max-width: 80%;
height: 100vh;
background-color: white;
transition: right .3s cubic-bezier(.35,.19,.45,.91);
}
.jet-menu-inner {
overflow-y: scroll;
display: block;
height: 100vh;
}
.jet-menu {
.jet-menu-item {
flex-flow: column nowrap;
max-width: 100%;
> a.top-level-link,
> a.sub-level-link {
border-radius: 0;
border-left: none;
border-right: none;
border-bottom-width: 1px;
.jet-menu-item-wrapper {}
.jet-dropdown-arrow {
width: 25px;
height: 25px;
display: flex;
justify-content: center;
align-items: center;
}
}
& > .jet-sub-menu {
border-radius: 0;
box-shadow: none;
}
& > .jet-sub-mega-menu {
border-radius: 0;
box-shadow: none;
}
&.jet-menu-hover {
& > .jet-sub-menu {
height: auto;
pointer-events: auto;
}
& > .jet-sub-mega-menu {
height: auto;
pointer-events: auto;
}
}
&:not(.jet-menu-hover) {
& > .jet-sub-menu {
padding: 0 !important;
border: none !important;
margin: 0 !important;
}
& > .jet-sub-mega-menu {
padding: 0 !important;
border: none !important;
margin: 0 !important;
}
}
}
}
.jet-sub-menu {
height: 0;
opacity: 1;
overflow: hidden;
visibility: visible;
}
.jet-mega-menu-item .jet-sub-mega-menu {
height: 0;
opacity: 1;
overflow: hidden;
visibility: visible;
max-width: 100% !important;
left: 0 !important;
width: 100% !important;
}
.jet-menu-item-has-children {
& > .jet-sub-menu {
padding-left: 20px;
}
}
}
.jet-mobile-menu-toggle-button {
width: 35px;
height: 35px;
display: none;
position: absolute;
padding: 0;
border-width: 0;
left: -45px;
top: 10px;
.jet-menu-toggle__icon {
@include font-awesome-icon;
display: flex;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
&::after {
top: .75em;
content: '\f0c9';
}
}
.jet-mobile-menu-visible & {
.jet-menu-toggle__icon {
&::after {
content: '\f00d';
}
}
}
}
.jet-mobile-menu-cover {
position: fixed;
display: block;
width: 100%;
height: 100vh;
top: 0;
left: 0;
opacity: 0;
visibility: hidden;
background-color: rgba( 0, 0, 0, 0.75 );
z-index: 997;
transition: opacity .3s cubic-bezier(.5,.12,.46,.88),
visibility .1s linear;
}
.jet-sub-mega-menu {
width: 100%;
display: block;
position: relative;
background-color: white;
pointer-events: none;
@media (min-width: 768px) {
position: absolute;
}
.jet-mobile-menu-active & {
position: relative;
}
.jet-desktop-menu-active & {
width: 100%;
display: block;
position: absolute;
top: 100%;
left: 0;
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.2 );
z-index: 999;
}
.jet-mega-menu-position-relative-item & {
left: 0 !important;
}
}
.jet-responsive-menu {
> li {
&[hidden] {
display: none;
}
}
&-available-items {
&[hidden] {
display: none;
}
}
}
body.jet-mobile-menu-visible {
overflow: hidden;
width: 100%;
height: auto;
.jet-mobile-menu-cover {
opacity: 1;
visibility: visible;
pointer-events: auto;
transition: opacity .3s cubic-bezier(.5,.12,.46,.88),
visibility .1s linear;
}
.jet-menu-container.jet-mobile-menu {
right: 0;
transition: all .5s cubic-bezier(.35,.19,.45,.91);
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}
}
.admin-bar.jet-mobile-menu-active {
.jet-mobile-menu-toggle-button {
top: 56px;
}
.jet-menu {
margin-top: 46px;
}
}
// FIX showing sub-menu and sub-mega-menu when loading a page.
.jet-sub-menu,
.jet-sub-mega-menu {
opacity: 0;
visibility: hidden;
}
.jet-desktop-menu-active {
.jet-menu--animation-type-none {
.jet-sub-menu {
opacity: 0;
visibility: hidden;
}
.jet-sub-mega-menu {
opacity: 0;
visibility: hidden;
}
.jet-simple-menu-item {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
li {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 0;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
.jet-mega-menu-item {
&.jet-menu-hover {
.jet-sub-mega-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
.jet-menu--animation-type-fade {
.jet-sub-menu {
opacity: 0;
visibility: hidden;
transition: opacity .3s cubic-bezier(.48,.01,.5,.99),
visibility .1s linear;
}
.jet-sub-mega-menu {
opacity: 0;
visibility: hidden;
transition: opacity .3s cubic-bezier(.48,.01,.5,.99),
visibility .1s linear;
}
.jet-simple-menu-item {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
li {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 0;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
.jet-mega-menu-item {
&.jet-menu-hover {
.jet-sub-mega-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
.jet-menu--animation-type-move-up {
.jet-sub-menu {
opacity: 0;
top: 130%;
visibility: hidden;
transition: top .2s cubic-bezier(.48,.01,.5,.99) .1s,
opacity .2s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear;
}
.jet-sub-mega-menu {
opacity: 0;
top: 130%;
visibility: hidden;
transition: top .3s cubic-bezier(.48,.01,.5,.99) .1s,
opacity .3s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear;
}
.jet-simple-menu-item {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
transition: top .3s cubic-bezier(.48,.01,.5,.99),
opacity .3s cubic-bezier(.48,.01,.5,.99),
visibility 1s linear;
}
}
li {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 0;
opacity: 1;
visibility: visible;
pointer-events: auto;
transition: top .3s cubic-bezier(.48,.01,.5,.99),
opacity .3s cubic-bezier(.48,.01,.5,.99),
visibility 1s linear;
}
}
}
}
.jet-mega-menu-item {
&.jet-menu-hover {
.jet-sub-mega-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
.jet-menu--animation-type-move-down {
.jet-sub-menu {
opacity: 0;
top: 80%;
visibility: visible;
transition: top .3s cubic-bezier(.48,.01,.5,.99),
opacity .3s cubic-bezier(.48,.01,.5,.99),
visibility 1s linear;
}
.jet-sub-mega-menu {
opacity: 0;
top: 80%;
visibility: hidden;
transition: top .3s cubic-bezier(.48,.01,.5,.99),
opacity .3s cubic-bezier(.48,.01,.5,.99),
visibility 1s linear;
}
.jet-simple-menu-item {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
li {
&.jet-menu-hover {
& > .jet-sub-menu {
top: 0;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
.jet-mega-menu-item {
&.jet-menu-hover {
.jet-sub-mega-menu {
top: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
}
}
}
}
}
// Prevent duplicate sub-menu and mega-menu when the section is sticky
.jet-desktop-menu-active {
.elementor-sticky--active + .elementor-sticky {
.jet-sub-menu,
.jet-sub-mega-menu {
display: none;
}
}
}
// if iphone and safari
.jet-mobile-menu .jet-menu.jet-menu--iphone-mode {
margin-bottom: 75px;
}

View File

@@ -0,0 +1,353 @@
.jet-custom-nav {
max-width: 100%;
position: relative;
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: stretch;
> .jet-custom-nav__item {
position: relative;
margin-bottom: 1px;
&.jet-custom-nav-mega-sub-position-top {
position: static;
}
> a {
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
padding: 10px 15px;
background-color: #54595f;
transition: all .5s cubic-bezier(.48,.01,.5,.99);
}
}
.jet-custom-nav__item {
&.hover-state {
& > .jet-custom-nav__mega-sub,
& > .jet-custom-nav__sub {
opacity: 1;
visibility: visible;
pointer-events: auto;
body[data-elementor-device-mode="mobile"] & {
height: auto;
}
}
}
}
.jet-menu-link-text {
color: white;
font-size: 14px;
.jet-custom-item-desc {
display: block;
font-size: 12px;
font-style: italic;
}
}
.jet-menu-icon {
display: flex;
justify-content: center;
align-items: center;
margin: 0 10px 0 0;
color: white;
border-radius: 50%;
width: 22px;
height: 22px;
&:before {
font-size: 12px;
color: #7a7a7a;
}
}
.jet-menu-badge {
margin: 0 0 0 10px;
width: 0;
.jet-menu-badge__inner {
padding: 3px 5px;
background-color: white;
color: #7a7a7a;
display: inline-block;
}
}
.jet-dropdown-arrow {
position: absolute;
right: 15px;
color: white;
font-size: 8px;
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
width: 14px;
height: 14px;
border-radius: 50%;
background-color: white;
&:before {
color: #7a7a7a;
}
}
&--dropdown-left-side {
> .jet-custom-nav__item,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__item {
> a {
text-align: right;
body:not(.rtl) & {
flex-direction: row-reverse;
}
.jet-menu-icon {
margin: 0 0 0 10px;
}
.jet-menu-badge {
direction: rtl;
margin: 0 10px 0 0;
}
.jet-dropdown-arrow {
left: 15px;
right: auto;
}
}
}
}
}
.jet-custom-nav__mega-sub,
.jet-custom-nav__sub {
display: block;
position: absolute;
margin: 0;
background-color: white;
list-style: none;
top: 0;
left: 100%;
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.2 );
opacity: 0;
visibility: hidden;
transition: opacity .3s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear .1s;
pointer-events: none;
z-index: 99;
&:before {
content: '';
position: absolute;
top: 0;
right: 100%;
bottom: 0;
}
body[data-elementor-device-mode="mobile"] & {
position: relative;
min-width: 0 !important;
width: 100%;
box-sizing:border-box;
overflow: hidden;
left: 0;
height: 0;
&:before {
content: none;
}
}
body[data-elementor-device-mode="mobile"] .jet-custom-nav .jet-custom-nav__item:not(.hover-state) & {
padding: 0;
margin: 0;
border: none;
}
}
.jet-custom-nav__mega-sub {
width: 500px;
.jet-custom-nav--dropdown-left-side > .jet-custom-nav__item > & {
left: auto;
right: 100%;
&:before {
left: 100%;
right: auto;
}
}
body[data-elementor-device-mode="mobile"] & {
width: 100% !important;
max-width: 100%;
}
.elementor-editor-active .elementor.elementor-edit-mode & > .elementor > .elementor-inner {
margin-top: 0;
}
}
.jet-custom-nav__sub {
min-width: 250px;
&.inverse-side {
left: auto;
right: 100%;
&:before {
left: 100%;
right: auto;
}
}
.jet-custom-nav--dropdown-left-side > .jet-custom-nav__item > &,
.jet-custom-nav--dropdown-left-side > .jet-custom-nav__item > & & {
left: auto;
right: 100%;
&:before {
left: 100%;
right: auto;
}
&.inverse-side {
right: auto;
left: 100%;
&:before {
left: auto;
right: 100%;
}
}
}
.jet-custom-nav__item {
position: relative;
a {
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
padding: 10px 15px;
background-color: #54595f;
transition: all .5s cubic-bezier(.48,.01,.5,.99);
.jet-menu-link-text {
color: white;
}
}
&.hover-state {
& > a {
background-color: #54595f;
.jet-menu-link-text {
color: white;
}
}
}
}
}
// Animations
.jet-custom-nav {
&--animation-none {
> .jet-custom-nav__item > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__sub {
transition: none;
}
}
&--animation-move-up {
> .jet-custom-nav__item > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__sub {
transform: translateY(20px);
transition: transform .2s cubic-bezier(.48,.01,.5,.99) .1s,
opacity .2s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear;
body[data-elementor-device-mode="mobile"] & {
transform: translateY(0);
}
}
> .jet-custom-nav__item.hover-state > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item.hover-state.hover-state > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__item.hover-state > .jet-custom-nav__sub{
transform: translateY(0);
}
}
&--animation-move-down {
> .jet-custom-nav__item > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__sub {
transform: translateY(-20px);
transition: transform .2s cubic-bezier(.48,.01,.5,.99) .1s,
opacity .2s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear;
body[data-elementor-device-mode="mobile"] & {
transform: translateY(0);
}
}
> .jet-custom-nav__item.hover-state > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item.hover-state.hover-state > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__item.hover-state > .jet-custom-nav__sub{
transform: translateY(0);
}
}
&--animation-move-left {
> .jet-custom-nav__item > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__sub {
transform: translateX(20px);
transition: transform .2s cubic-bezier(.48,.01,.5,.99) .1s,
opacity .2s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear;
body[data-elementor-device-mode="mobile"] & {
transform: translateX(0);
}
}
> .jet-custom-nav__item.hover-state > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item.hover-state.hover-state > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__item.hover-state > .jet-custom-nav__sub{
transform: translateX(0);
}
}
&--animation-move-right {
> .jet-custom-nav__item > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__sub {
transform: translateX(-20px);
transition: transform .2s cubic-bezier(.48,.01,.5,.99) .1s,
opacity .2s cubic-bezier(.48,.01,.5,.99) .1s,
visibility 1s linear;
body[data-elementor-device-mode="mobile"] & {
transform: translateX(0);
}
}
> .jet-custom-nav__item.hover-state > .jet-custom-nav__mega-sub,
> .jet-custom-nav__item.hover-state.hover-state > .jet-custom-nav__sub,
> .jet-custom-nav__item > .jet-custom-nav__sub .jet-custom-nav__item.hover-state > .jet-custom-nav__sub{
transform: translateX(0);
}
}
}

View File

@@ -0,0 +1,485 @@
<?php
/**
* Class Cherry Core
* Version: 1.5.11
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2016, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Core' ) ) {
/**
* Class Cherry Core.
*/
class Cherry_Core {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Core settings.
*
* @since 1.0.0
* @var array
*/
public $settings = array();
/**
* Holder for all registered modules for current core instance.
*
* @since 1.0.0
* @var array
*/
public $modules = array();
/**
* Holder for all modules.
*
* @since 1.1.0
* @var array
*/
public static $all_modules = array();
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct( $settings = array() ) {
global $chery_core_version;
$defaults = array(
'framework_path' => 'cherry-framework',
'modules' => array(),
'base_dir' => '',
'base_url' => '',
);
$this->settings = array_merge( $defaults, $settings );
if ( isset( $chery_core_version ) && 0 < sizeof( $chery_core_version ) ) {
$core_paths = array_values( $chery_core_version );
$path_parts = pathinfo( $core_paths[0] );
$this->settings['base_dir'] = trailingslashit( $path_parts['dirname'] );
} else {
// This condition and the using of the function dirname is due to core backwards compatibility with old framework versions
$this->settings['base_dir'] = trailingslashit( dirname( __FILE__ ) );
}
$this->settings['base_url'] = trailingslashit( $this->base_url( '', $this->settings['base_dir'] ) );
$this->run_collector();
/**
* In this hooks priority parameter are very important.
*/
add_action( 'after_setup_theme', array( 'Cherry_Core', 'load_all_modules' ), 2 );
add_action( 'after_setup_theme', array( $this, 'init_required_modules' ), 2 );
// Load the framework textdomain.
add_action( 'after_setup_theme', array( $this, 'load_textdomain' ), 10 );
// Init modules with autoload seted up into true.
add_action( 'after_setup_theme', array( $this, 'init_autoload_modules' ), 9999 );
// Backward compatibility for `cherry-widget-factory` module.
remove_all_filters( 'cherry_widget_factory_core', 10 );
add_filter( 'cherry_widget_factory_core', array( $this, 'pass_core_to_widgets' ), 11, 2 );
}
/**
* Fire collector for modules.
*
* @since 1.0.0
* @return bool
*/
private function run_collector() {
if ( ! is_array( $this->settings['modules'] ) || empty( $this->settings['modules'] ) ) {
return false;
}
// Cherry_Toolkit module should be loaded by default.
if ( ! isset( $this->settings['modules']['cherry-toolkit'] ) ) {
$this->settings['modules']['cherry-toolkit'] = array(
'autoload' => true,
);
}
foreach ( $this->settings['modules'] as $module => $settings ) {
$file_path = $this->get_module_file( $module );
if ( ! array_key_exists( $module, self::$all_modules ) ) {
self::$all_modules[ $module ] = $file_path;
}
}
/**
* Filter a holder for all modules.
*
* @since 1.1.0
* @var array
*/
self::$all_modules = apply_filters( 'cherry_core_all_modules', self::$all_modules, $this );
}
/**
* Loaded all modules.
*
* @since 1.1.0
*/
public static function load_all_modules() {
foreach ( self::$all_modules as $module => $path ) {
$loaded = self::load_module( $module, $path );
if ( ! $loaded ) {
continue;
}
}
}
/**
* Load the framework textdomain.
*
* @since 1.4.0
*/
public function load_textdomain() {
$mo_file_path = $this->settings['base_dir'] . 'languages/' . get_locale() . '.mo';
load_textdomain( 'cherry-framework', $mo_file_path );
}
/**
* Init a required modules.
*
* @since 1.1.0
*/
public function init_required_modules() {
$required_modules = apply_filters( 'cherry_core_required_modules', array(
'cherry-toolkit',
'cherry-widget-factory',
), $this );
foreach ( $required_modules as $module ) {
if ( ! array_key_exists( $module, $this->settings['modules'] ) ) {
continue;
}
$settings = $this->settings['modules'][ $module ];
$args = ! empty( $settings['args'] ) ? $settings['args'] : array();
$this->init_module( $module, $args );
}
}
/**
* Init autoload modules.
*
* @since 1.1.0
*/
public function init_autoload_modules() {
if ( empty( $this->modules ) ) {
return;
}
foreach ( $this->settings['modules'] as $module => $settings ) {
if ( ! $this->is_module_autoload( $module ) ) {
continue;
}
if ( ! empty( $this->modules[ $module ] ) ) {
continue;
}
$args = ! empty( $settings['args'] ) ? $settings['args'] : array();
$this->init_module( $module, $args );
}
}
/**
* Init single module.
*
* @since 1.0.0
* @param string $module Module slug.
* @param array $args Module arguments array.
* @return mixed
*/
public function init_module( $module, $args = array() ) {
if ( empty( $args[ 'module_path' ] ) ) {
$get_module_path = $this->get_module_path( $module );
$args['module_path'] = ( $get_module_path ) ? $get_module_path : '';
}
$this->modules[ $module ] = $this->get_module_instance( $module, $args );
/**
* Filter a single module after initialization.
*
* @since 1.1.0
*/
return apply_filters( 'cherry_core_init_module', $this->modules[ $module ], $module, $args, $this );
}
/**
* Check module autoload.
*
* @since 1.0.0
* @param string $module Module slug.
* @return bool
*/
public function is_module_autoload( $module ) {
if ( empty( $this->settings['modules'][ $module ]['autoload'] ) ) {
return false;
}
return $this->settings['modules'][ $module ]['autoload'];
}
/**
* Include module.
*
* @since 1.0.0
* @param string $module Module slug.
* @param string $path Module path.
* @return bool
*/
public static function load_module( $module, $path ) {
if (
'cherry-interface-builder' === $module
&& file_exists( str_replace( 'cherry-interface-builder', 'cherry5-interface-builder', $path ) )
) {
$module = 'cherry5-interface-builder';
$path = str_replace( 'cherry-interface-builder', 'cherry5-interface-builder', $path );
}
$class_name = self::get_class_name( $module );
if ( ! $path ) {
return false;
}
if ( class_exists( $class_name ) ) {
return true;
}
require_once( $path );
return true;
}
/**
* Get module instance.
*
* @since 1.0.0
* @param string $module Module slug.
* @param array $args Module arguments.
* @return object
*/
public function get_module_instance( $module, $args = array() ) {
$class_name = self::get_class_name( $module );
if (
'cherry-interface-builder' === $module
&& class_exists( self::get_class_name( 'cherry5-interface-builder' ) ) ) {
$class_name = self::get_class_name( 'cherry5-interface-builder' );
}
if ( ! class_exists( $class_name ) ) {
echo '<p>Class <b>' . esc_html( $class_name ) . '</b> not exist!</p>';
return false;
}
$this->modules[ $module ] = call_user_func( array( $class_name, 'get_instance' ), $this, $args );
return $this->modules[ $module ];
}
/**
* Get class name by module slug.
*
* @since 1.0.0
* @param string $slug Module slug.
* @return string
*/
public static function get_class_name( $slug = '' ) {
$slug = str_replace( '-', ' ', $slug );
$class = str_replace( ' ', '_', ucwords( $slug ) );
return $class;
}
/**
* Get path to main file for passed module.
*
* @since 1.0.1
* @param string $module Module slug.
* @return string
*/
public function get_module_path( $module ) {
$abs_path = false;
$rel_path = 'modules/' . $module . '/';
if ( file_exists( $this->settings['base_dir'] . $rel_path ) ) {
$abs_path = $this->settings['base_dir'] . $rel_path;
}
return $abs_path;
}
/**
* Get path to main file for passed module.
*
* @since 1.0.1
* @param string $module Module slug.
* @return string
*/
public function get_module_file( $module ) {
$abs_path = false;
$rel_path = 'modules/' . $module . '/' . $module . '.php';
if ( file_exists( $this->settings['base_dir'] . $rel_path ) ) {
$abs_path = $this->settings['base_dir'] . $rel_path;
}
return $abs_path;
}
/**
* Retrieves the absolute URL to the current file.
* Like a WordPress function `plugins_url`.
*
* @link https://codex.wordpress.org/Function_Reference/plugins_url
* @since 1.0.1
* @param string $file_path Optional. Extra path appended to the end of the URL.
* @param string $module_path A full path to the core or module file.
* @return string
*/
public static function base_url( $file_path = '', $module_path ) {
$module_path = wp_normalize_path( $module_path );
preg_match( '/\.[0-9a-z]+$/', $module_path, $ext );
if ( empty( $ext ) ) {
$module_dir = $module_path;
} else {
// This condition and the using of the function dirname is due to core backwards compatibility with old framework versions
$module_dir = dirname( $module_path );
}
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$stylesheet = get_stylesheet();
$theme_root = get_raw_theme_root( $stylesheet );
$theme_dir = "$theme_root/$stylesheet";
if ( 0 === strpos( $module_dir, $plugin_dir ) ) {
$site_url = site_url();
$abs_path = wp_normalize_path( ABSPATH );
$url = str_replace( untrailingslashit( $abs_path ), $site_url, $module_dir );
} else if ( false !== strpos( $module_path, $theme_dir ) ) {
$explode = explode( $theme_dir, $module_dir );
$url = get_stylesheet_directory_uri() . end( $explode );
} else {
$site_url = site_url();
$abs_path = wp_normalize_path( ABSPATH );
$url = str_replace( untrailingslashit( $abs_path ), $site_url, $module_dir );
}
if ( $file_path && is_string( $file_path ) ) {
$url = trailingslashit( $url );
$url .= ltrim( $file_path, '/' );
}
return apply_filters( 'cherry_core_base_url', $url, $file_path, $module_path );
}
/**
* Pass core instance into widget.
*
* @since 1.1.0
* @param mixed $core Current core object.
* @param string $path Abstract widget file path.
* @return mixed
*/
public function pass_core_to_widgets( $core, $path ) {
$path = str_replace( '\\', '/', $path );
$current_core = str_replace( '\\', '/', $this->settings['base_dir'] );
if ( false !== strpos( $path, $current_core ) ) {
return self::get_instance();
}
return $core;
}
/**
* Get core version.
*
* @since 1.5.0
* @return string
*/
public function get_core_version() {
global $chery_core_version;
return key( $chery_core_version );
}
/**
* Get path to the core directory.
*
* @since 1.0.0
* @return string
*/
public function get_core_dir() {
return trailingslashit( $this->settings['base_dir'] );
}
/**
* Get URI to the core directory.
*
* @since 1.0.0
* @deprecated 1.1.0 Use `base_url()` method
* @return string
*/
public function get_core_url() {
return trailingslashit( $this->settings['base_url'] );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,196 @@
{
"name" : "Cherry Framework",
"version" : "1.4.3.1",
"description" : "",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs",
"git_link" : "https://github.com/CherryFramework/cherry-framework",
"modules" : {
"cherry-breadcrumbs" : {
"name" : "Breadcrumb Trail",
"description" : "A breadcrumb menu script for WordPress.",
"version" : "1.1.3",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-breadcrumbs",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-customizer" : {
"name" : "Customizer API",
"description" : "Customizer functionality.",
"version" : "1.1.7",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/01.%20cherry-customizer.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-customizer",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-db-updater" : {
"name" : "Database Updater",
"description" : "Handle database updates if required.",
"version" : "1.0.0",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-db-updater",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-dynamic-css" : {
"name" : "Dynamic CSS",
"description" : "Generate CSS.",
"version" : "1.4.0",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/03.%20cherry-dynamic-css.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-dynamic-css",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-google-fonts-loader" : {
"name" : "Google Fonts Loader",
"description" : "Enqueue Google fonts.",
"version" : "1.1.0",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-google-fonts-loader",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-handler" : {
"name" : "Cherry handler",
"description" : "Initialize handlers.",
"version" : "1.1.3",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/02.%20cherry-handler.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-handler",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-js-core" ]
},
"cherry-interface-builder" : {
"name" : "Interface Builder",
"description" : "The module for the creation of interfaces in the WordPress admin panel.",
"version" : "1.1.2",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/07.%20cherry-interface-builder.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-interface-builder",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-ui-elements" ]
},
"cherry-js-core" : {
"name" : "JS Core",
"description" : "Initialize global JS object which provides additional plugin functionality.",
"version" : "1.1.2",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/04.%20cherry-js-core.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-js-core",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-post-formats-api" : {
"name" : "Post Formats API",
"description" : "API for post formats specific content.",
"version" : "1.1.2",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-formats-api",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-js-core" ]
},
"cherry-post-meta" : {
"name" : "Post Meta",
"description" : "Manage post meta.",
"version" : "1.2.1",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-meta",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-interface-builder" ]
},
"cherry-term-meta" : {
"name" : "Term Meta",
"description" : "Manage term metadata.",
"version" : "1.1.4",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-term-meta",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-ui-elements" ]
},
"cherry-toolkit": {
"name": "Framework Toolkit",
"description": "Framework Toolkit contains various PHP utilities",
"version" : "1.2.0",
"doc_link": "https://github.com/CherryFramework/cherry-framework-docs/blob/master/100.%20cherry-toolkit.md",
"git_link": "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-toolkit",
"compatible": ["theme", "plugin"],
"wordpress_org": true,
"required": true,
"dependencies": []
},
"cherry-ui-elements" : {
"name" : "UI Elements",
"description" : "UI Elements",
"version" : "1.4.3",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/09.%20cherry-ui-elements.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-ui-elements",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-js-core" ]
},
"cherry-utility" : {
"name" : "Utility",
"description" : "Multiple utility functions.",
"version" : "1.1.7",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/08.%20cherry-utility.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-utility",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : []
},
"cherry-widget-factory" : {
"name" : "Widget Factory",
"description" : "Base widget class that simplifies creating of your own widgets.",
"version" : "1.2.1",
"doc_link" : "https://github.com/CherryFramework/cherry-framework-docs/blob/master/06.%20cherry-widget-factory.md",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-widget-factory",
"compatible" : ["theme", "plugin"],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-ui-elements" ]
},
"cherry5-assets-loader" : {
"name" : "Assets Loader",
"description" : "The module allows you deferred loading scripts and styles.",
"version" : "1.0.0",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry5-assets-loader",
"compatible" : [ "theme", "plugin" ],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-js-core" ]
},
"cherry5-insert-shortcode" : {
"name" : "Insert Shortcode",
"description" : "The module allows you to add shortcodes from editor tinyMCE.",
"version" : "1.0.2",
"doc_link" : "",
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry5-insert-shortcode",
"compatible" : [ "plugin" ],
"wordpress_org" : true,
"required" : false,
"dependencies" : [ "cherry-ui-elements", "cherry-interface-builder" ]
}
}
}

View File

@@ -0,0 +1,119 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: cherry-framework\n"
"POT-Creation-Date: 2016-12-26 14:10+0200\n"
"PO-Revision-Date: 2016-12-09 16:29+0200\n"
"Last-Translator: \n"
"Language-Team: TemplateMonster\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.11\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_n_noop:1,2;_x:1,2c;_nx:1,2,4c;"
"_nx_noop:1,2,3c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;"
"esc_html_e;esc_html_x:1,2c\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPath-1: .\n"
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:346
msgid "Home"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:352
msgid "Browse:"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:354
msgid "404 Not Found"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:355
msgid "Archives"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:356
#, php-format
msgid "Search results for &#8220;%s&#8221;"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:357
#, php-format
msgid "Page %s"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:358
#, php-format
msgid "Minute %s"
msgstr ""
#: modules/cherry-breadcrumbs/cherry-breadcrumbs.php:359
#, php-format
msgid "Week %s"
msgstr ""
#: modules/cherry-customizer/cherry-customizer.php:269
msgid "Untitled Panel"
msgstr ""
#: modules/cherry-customizer/cherry-customizer.php:305
msgid "Untitled Section"
msgstr ""
#: modules/cherry-customizer/cherry-customizer.php:338
msgid "Untitled Control"
msgstr ""
#: modules/cherry-db-updater/cherry-db-updater.php:105
#, php-format
msgid ""
"Module DB Updater init error in %s - version and slug is required arguments"
msgstr ""
#: modules/cherry-db-updater/cherry-db-updater.php:106
msgid "We need to update your database to the latest version."
msgstr ""
#: modules/cherry-db-updater/cherry-db-updater.php:107
msgid "Update complete, thank you for updating to the latest version!"
msgstr ""
#: modules/cherry-db-updater/cherry-db-updater.php:331
msgid "Start Update"
msgstr ""
#: modules/cherry-db-updater/cherry-db-updater.php:368
msgid "Data Update"
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-button.php:63
msgid "Cherry shortcodes"
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-popup.php:128
msgid "insert shortcode"
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-popup.php:148
msgid "Shortcode List"
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-popup.php:206
msgid "Shortcode not found."
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-popup.php:261
msgid "Shortcode content."
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-popup.php:262
msgid "Input shortcode content."
msgstr ""
#: modules/cherry5-insert-shortcode/inc/class-cherry5-insertion-popup.php:277
msgid "Shortcode not a have options."
msgstr ""

View File

@@ -0,0 +1,209 @@
{
"kind": "standartfonts#standartfonts",
"items": [
{
"kind": "standartfonts#standartfonts",
"family": "Arial, Helvetica",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfonts",
"family": "Arial Black, Gadget",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Bookman Old Style",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Comic Sans MS",
"category": "cursive",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Courier",
"category": "monospace",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Garamond",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Georgia",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Impact, Charcoal",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Lucida Console, Monaco",
"category": "monospace",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Lucida Sans Unicode, Lucida Grande",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "MS Sans Serif, Geneva",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "MS Serif, New York",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Palatino Linotype, Book Antiqua, Palatino",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Tahoma, Geneva",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Times New Roman, Times",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Trebuchet MS, Helvetica",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Verdana, Geneva",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
}
]
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Iconpicker customizer control
*
* @package Cherry_Framework
* @subpackage Modules/Customizer
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
if ( class_exists( 'WP_Customize_Control' ) ) {
/**
* Iconpicker control for customizer
*/
class Cherry_WP_Customize_Iconpicker extends WP_Customize_Control {
/**
* Icons data array
*
* @see cherry-ui-elements/inc/ui-elements/ui-iconpicker/ui-iconpicker.php for data array format.
* @var array
*/
public $icon_data = array();
/**
* Trigger to try automatically parse icons from CSS file or not.
*
* @var boolean
*/
public $auto_parse = false;
/**
* UI instance
*
* @var object
*/
private $iconpicker = null;
/**
* Render the control's content.
*/
public function render_content() {
?>
<label>
<span class="customize-control-title">
<?php echo esc_html( $this->label ); ?>
</span>
<?php if ( isset( $this->description ) ) : ?>
<span class="description customize-control-description">
<?php echo wp_kses_post( $this->description ); ?>
</span>
<?php endif; ?>
</label>
<?php
echo str_replace(
'id="' . $this->id . '"',
'id="' . $this->id . '" ' . $this->get_link(),
$this->iconpicker->render()
);
}
/**
* Enqueue assets
*/
public function enqueue() {
$core = apply_filters( 'cherry_customizer_get_core', false );
$ui_builder = $core->init_module(
'cherry-ui-elements',
array(
'ui_elements' => array( 'iconpicker' ),
)
);
$args = array(
'type' => 'iconpicker',
'id' => $this->id,
'name' => $this->id,
'value' => $this->value(),
'icon_data' => $this->icon_data,
'auto_parse' => $this->auto_parse,
);
add_action( 'customize_controls_print_styles', array( $this, 'print_sets' ) );
$this->iconpicker = $ui_builder->get_ui_element_instance( 'iconpicker', $args );
$this->iconpicker->enqueue_assets();
}
/**
* Print JS var with sets data
*
* @return void
*/
public function print_sets() {
$this->iconpicker->prepare_icon_set();
UI_Iconpicker::$printed = false;
$this->iconpicker->print_icon_set();
}
}
}

View File

@@ -0,0 +1,379 @@
<?php
/**
* Module Name: Database Updater
* Description: Handle database updates if required.
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Db_Updater
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Db_Updater' ) ) {
/**
* Class Cherry Db Updater.
*
* @since 1.0.0
*/
class Cherry_Db_Updater {
/**
* Module arguments.
*
* @since 1.0.0
* @var array
*/
private $args = array(
'callbacks' => array(),
'slug' => null,
'version' => null,
);
/**
* Option key for DB version.
*
* @since 1.0.0
* @var string
*/
protected $version_key = '%s-db-version';
/**
* Nonce format.
*
* @since 1.0.0
* @var string
*/
protected $nonce = '_%s-db-update-nonce';
/**
* Messages array.
*
* @since 1.0.0
* @var array
*/
protected $messages = array();
/**
* Update done trigger.
*
* @since 1.0.0
* @var bool
*/
protected $updated = false;
/**
* Core instance.
*
* @since 1.0.0
* @var object
*/
public $core = null;
/**
* Cherry_Db_Updater constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct( $core = null, $args = array() ) {
$this->core = $core;
$this->args = wp_parse_args( $args, $this->args );
if ( ! is_admin() || ! current_user_can( 'update_plugins' ) ) {
return;
}
add_action( 'admin_notices', array( $this, 'init_notices' ) );
add_action( 'admin_init', array( $this, 'do_update' ) );
$this->messages = array(
'error' => esc_html__( 'Module DB Updater init error in %s - version and slug is required arguments', 'cherry-framework' ),
'update' => esc_html__( 'We need to update your database to the latest version.', 'cherry-framework' ),
'updated' => esc_html__( 'Update complete, thank you for updating to the latest version!', 'cherry-framework' ),
);
}
/**
* Process DB update.
*
* @since 1.0.0
*/
public function do_update() {
if ( ! $this->is_current_update() ) {
return;
}
$callbacks = $this->prepare_callbacks();
if ( ! empty( $callbacks ) ) {
foreach ( $callbacks as $callback ) {
if ( is_callable( $callback ) ) {
call_user_func( $callback );
}
}
}
$this->set_updated();
}
/**
* Finalize update.
*
* @since 1.0.0
*/
public function set_updated() {
$this->updated = true;
$option = sprintf( $this->version_key, esc_attr( $this->args['slug'] ) );
update_option( $option, esc_attr( $this->args['version'] ) );
}
/**
* Prepare callbacks array.
*
* @since 1.0.0
* @return array
*/
private function prepare_callbacks() {
$callbacks = array();
if ( empty( $this->args['callbacks'] ) ) {
return $callbacks;
}
ksort( $this->args['callbacks'] );
foreach ( $this->args['callbacks'] as $ver => $ver_cb ) {
if ( version_compare( $this->get_current_version(), $ver, '<' ) ) {
$callbacks = array_merge( $callbacks, $ver_cb );
}
}
return $callbacks;
}
/**
* Check if we processed update for plugin passed in arguments.
*
* @since 1.0.0
* @return bool
*/
private function is_current_update() {
if ( empty( $_GET['cherry_db_update'] ) || empty( $_GET['slug'] ) || empty( $_GET['_nonce'] ) ) {
return false;
}
if ( $_GET['slug'] !== $this->args['slug'] ) {
return false;
}
$nonce_action = sprintf( $this->nonce, esc_attr( $this->args['slug'] ) );
if ( ! wp_verify_nonce( $_GET['_nonce'], $nonce_action ) ) {
return false;
}
return true;
}
/**
* Init admin notices.
*
* @since 1.0.0
* @return void
*/
public function init_notices() {
$enabled = $this->validate_module_args();
if ( ! $enabled ) {
return;
}
$slug = esc_attr( $this->args['slug'] );
if ( $this->is_update_required() ) {
$this->show_notice( $slug );
}
if ( $this->is_updated() ) {
$this->show_updated_notice( $slug );
}
}
/**
* Returns current DB version.
*
* @since 1.0.0
* @return string
*/
private function get_current_version() {
$option = sprintf( $this->version_key, esc_attr( $this->args['slug'] ) );
return get_option( $option, '1.0.0' );
}
/**
* Check if database requires update.
*
* @since 1.0.0
* @return bool
*/
private function is_update_required() {
$current = $this->get_current_version();
return version_compare( $current, esc_attr( $this->args['version'] ), '<' );
}
/**
* Check if update was succesfully done.
*
* @since 1.0.0
* @return bool
*/
private function is_updated() {
if ( ! $this->is_current_update() ) {
return false;
}
return (bool) $this->updated;
}
/**
* Validate module arguments.
*
* @since 1.0.0
* @return bool
*/
private function validate_module_args() {
if ( empty( $this->args['slug'] ) || empty( $this->args['version'] ) ) {
echo '<div class="error"><p>';
printf(
$this->messages['error'],
'<b>' . str_replace( untrailingslashit( ABSPATH ), '', $this->core->settings['base_dir'] ) . '</b>'
);
echo '</p></div>';
return false;
}
return true;
}
/**
* Show notice.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function show_notice( $slug ) {
echo '<div class="notice notice-info">';
echo '<p>';
$this->notice_title( $slug );
echo $this->messages['update'];
echo '</p>';
echo '<p>';
$this->notice_submit( $slug );
echo '</p>';
echo '</div>';
}
/**
* Show update notice.
*
* @since 1.0.0
* @return void
*/
private function show_updated_notice() {
$slug = esc_attr( $this->args['slug'] );
echo '<div class="notice notice-success is-dismissible">';
echo '<p>';
$this->notice_title( $slug );
echo $this->messages['updated'];
echo '</p>';
echo '</div>';
}
/**
* Show plugin notice submit button.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function notice_submit( $slug = '' ) {
$format = '<a href="%1s" class="button button-primary">%2$s</a>';
$label = esc_html__( 'Start Update', 'cherry-framework' );
$url = add_query_arg(
array(
'cherry_db_update' => true,
'slug' => $slug,
'_nonce' => $this->create_nonce( $slug ),
),
esc_url( admin_url( 'index.php' ) )
);
printf( $format, $url, $label );
}
/**
* Create DB update nonce.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return string
*/
private function create_nonce( $slug ) {
return wp_create_nonce( sprintf( $this->nonce, $slug ) );
}
/**
* Show plugin notice title.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function notice_title( $slug ) {
$name = str_replace( '-', ' ', $slug );
$name = ucwords( $name );
printf( '<strong>%1$s %2$s</strong> &#8211; ', $name, esc_html__( 'Data Update', 'cherry-framework' ) );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core = null, $args = array() ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,24 @@
/**
* Handler for CSS Collector
*/
function CherryCSSCollector() {
'use strict';
var style,
collectedCSS = window.CherryCollectedCSS;
if ( undefined !== collectedCSS ) {
style = document.createElement( 'style' );
style.setAttribute( 'title', collectedCSS.title );
style.setAttribute( 'type', collectedCSS.type );
style.textContent = collectedCSS.css;
document.head.appendChild( style );
}
}
CherryCSSCollector();

View File

@@ -0,0 +1 @@
function CherryCSSCollector(){"use strict";var t,e=window.CherryCollectedCSS;void 0!==e&&(t=document.createElement("style"),t.setAttribute("title",e.title),t.setAttribute("type",e.type),t.textContent=e.css,document.head.appendChild(t))}CherryCSSCollector();

View File

@@ -0,0 +1,543 @@
<?php
/**
* Module Name: Dynamic CSS
* Description: CSS parser which uses variables & functions for CSS code optimization
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Dynamic_Css' ) ) {
/**
* Dynamic CSS parser
*/
class Cherry_Dynamic_Css {
/**
* Module arguments
*
* @var array
*/
public $args = array();
/**
* Core instance
*
* @var object
*/
public $core = null;
/**
* Holder for processed variables array
*
* @var array
*/
public $variables = null;
/**
* Variable pattern
*
* @var array
*/
public $var_pattern = '/\$(([-_a-zA-Z0-9]+)(\[[\'\"]*([-_a-zA-Z0-9]+)[\'\"]*\])?({([a-z%]+)})?)/';
/**
* Function pattern
*
* @var array
*/
public $func_pattern = '/@(([a-zA-Z_]+)\(([^@\)]*)?\))/';
/**
* Collector instance holder
*
* @since 1.2.0
* @var object
*/
public static $collector = null;
/**
* Reserved words list
*
* @since 1.4.0
* @var array
*/
public $css_reserved = array(
'media',
'supports',
);
/**
* Constructor for the module
*/
function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args( $args, array(
'prefix' => 'blank',
'type' => 'theme_mod',
'parent_handle' => false,
'single' => true,
'css_files' => null,
'options' => array(),
) );
$this->init_dynamic_css();
$this->init_collector();
}
/**
* Initalize dynamic CSS with fallback compatibility.
*
* @since 1.3.0
* @return void
*/
public function init_dynamic_css() {
/**
* Not actual for now, required only for fallback compatibility.
*/
if ( empty( $this->args['parent_handle'] ) ) {
add_action( 'wp_head', array( $this, 'print_inline_css' ), 99 );
}
add_action( 'wp_enqueue_scripts', array( $this, 'add_inline_css' ), 99 );
}
/**
* Adds inline CSS into queue
*
* @since 1.3.0
* @return void
*/
public function add_inline_css() {
wp_add_inline_style( $this->args['parent_handle'], $this->get_inline_css() );
}
/**
* Initalize CSS collector class
*
* @since 1.2.0
* @return bool
*/
public function init_collector() {
if ( null !== self::$collector ) {
return true;
}
require_once 'inc/class-cherry-dynamic-css-collector.php';
ob_start();
include 'assets/min/cherry-css-collector.min.js';
$handler = ob_get_clean();
self::$collector = Cherry_Dynamic_Css_Collector::get_instance( $handler );
add_action( 'wp_footer', array( self::$collector, 'print_style' ), 11 );
add_action( 'wp_footer', array( self::$collector, 'add_js_handler' ), 11 );
return true;
}
/**
* Add new style to collector
*
* @since 1.2.0
* @param string $selector CSS selector to add styles for.
* @param array $style Styles array to add.
* @param array $media Media breakpoints.
* @return void
*/
public function add_style( $selector, $style = array(), $media = array() ) {
if ( ! $selector ) {
return;
}
self::$collector->add_style( $selector, $style, $media );
}
/**
* Get CSS variables into array
*
* @since 1.0.0
* @return array dynamic CSS variables
*/
public function get_css_varaibles() {
if ( null !== $this->variables ) {
return $this->variables;
}
$variables = $this->get_standard_vars();
$var_list = ! empty( $this->args['options'] ) ? $this->args['options'] : array();
/**
* Filter options names list to use it as varaibles
*
* @since 1.0.0
* @param array $var_list default variables list.
* @param array $this->args module arguments.
*/
$var_list = apply_filters( 'cherry_css_var_list', $var_list, $this->args );
if ( empty( $var_list ) ) {
return $variables;
}
$custom_vars = array();
foreach ( $var_list as $var ) {
$custom_vars[ $var ] = $this->get_setting( $var );
}
$variables = array_merge( $variables, $custom_vars );
/**
* Filter result variables list with values
*
* @since 1.0.0
* @param array $variables default variables list.
* @param array $this->args module arguments.
*/
$this->variables = apply_filters( 'cherry_css_variables', $variables, $this->args );
return $this->variables;
}
/**
* Get current setting by name
*
* @since 1.0.0
* @return mixed
*/
public function get_setting( $name ) {
$type = $this->args['type'];
if ( 'theme_mod' == $type ) {
$setting = get_theme_mod( $name );
return $setting;
}
if ( true != $this->args['single'] ) {
$setting = get_option( $name );
return $setting;
}
$settings = get_option( $this->args['prefix'] );
if ( ! empty( $settings ) && isset( $settings[ $name ] ) ) {
return $settings[ $name ];
}
return false;
}
/**
* Get standard WordPress variables from customizer - header image, background image etc.
*
* @since 1.0.0
* @return array
*/
public function get_standard_vars() {
$standard_vars = array(
'header_image',
'background_image',
'background_repeat',
'background_position_x',
'background_attachment',
);
$result = array();
foreach ( $standard_vars as $var ) {
$result[ $var ] = get_theme_mod( $var );
}
return $result;
}
/**
* Get avaliable functions into array
*
* @since 1.0.0
* @return array dynamic CSS variables
*/
public function get_css_functions() {
require_once 'inc/class-cherry-dynamic-css-utilities.php';
$utilities = Cherry_Dynamic_Css_Utilities::get_instance();
$func_list = array(
'darken' => array( $utilities, 'color_darken' ),
'lighten' => array( $utilities, 'color_lighten' ),
'contrast' => array( $utilities, 'color_contrast' ),
'alpha' => array( $utilities, 'color_alpha' ),
'background' => array( $utilities, 'background_css' ),
'background_url' => array( $utilities, 'background_url' ),
'typography' => array( $utilities, 'get_typography_css' ),
'box' => array( $utilities, 'get_box_model_css' ),
'emph' => array( $utilities, 'element_emphasis' ),
'font_family' => array( $utilities, 'typography_font_family' ),
'font_size' => array( $utilities, 'typography_size' ),
'container_compare' => array( $utilities, 'container_width_compare' ),
'sum' => array( $utilities, 'simple_sum' ),
'diff' => array( $utilities, 'simple_diff' ),
'menu_toogle_endpoint' => array( $utilities, 'menu_toogle_endpoint' ),
);
/**
* Filter available CSS functions list
*
* @since 1.0.0
* @param array $func_list default functions list.
* @param array $this->args module arguments.
*/
return apply_filters( 'cherry_css_func_list', $func_list, $this->args );
}
/**
* Parse CSS string and replasce varaibles and functions
*
* @since 1.0.0
* @param [type] $css CSS to parse.
* @return string
*/
public function parse( $css ) {
$replce_vars = preg_replace_callback( $this->var_pattern, array( $this, 'replace_vars' ), $css );
$replace_func = preg_replace_callback( $this->func_pattern, array( $this, 'replace_func' ), $replce_vars );
$result = preg_replace( '/\t|\r|\n|\s{2,}/', '', $replace_func );
return $result;
}
/**
* Returns complied dynamic CSS string.
*
* @since 1.3.0
* @return string|bool false
*/
public function get_inline_css() {
if ( ! $this->args['css_files'] ) {
return false;
}
if ( ! is_array( $this->args['css_files'] ) ) {
$this->args['css_files'] = array( $this->args['css_files'] );
}
/**
* Filter CSS reserved words list
*
* @since 1.4.0
* @var array
*/
$this->css_reserved = apply_filters( 'cherry_dynamic_css_reserved_words_list', $this->css_reserved );
ob_start();
foreach ( $this->args['css_files'] as $file ) {
if ( ! file_exists( $file ) ) {
continue;
}
include $file;
}
/**
* Allow to include custom dynamic CSS files
*
* @since 1.0.0
* @param array $this->args Current dynamic CSS arguments array.
* @param array $this->core Current core instance.
*/
do_action( 'cherry_dynamic_css_include_custom_files', $this->args, $this->core );
$css = ob_get_clean();
$parsed_css = $this->parse( $css );
/**
* Filter parsed dynamic CSS
*
* @since 1.0.0
* @param string $parsed_css default functions list.
* @param array $this->args module arguments.
*/
$parsed_css = apply_filters( 'cherry_dynamic_css_parsed_styles', $parsed_css, $this->args );
return $parsed_css;
}
/**
* Print inline CSS after current theme stylesheet
*
* @since 1.0.0
* @return void|bool false
*/
public function print_inline_css() {
$parsed_css = $this->get_inline_css();
if ( empty( $parsed_css ) ) {
return false;
}
printf( '<style type="text/css">%s</style>', $parsed_css );
}
/**
* Callback function to replace CSS vars
*
* @since 1.0.0
* @param [string] $matches founded vars.
*/
function replace_vars( $matches ) {
$not_found = '/* Variable not found */';
// check if variable name found
if ( empty( $matches[2] ) ) {
return $not_found;
}
$variables = $this->get_css_varaibles();
// check if var exists
if ( ! array_key_exists( $matches[2], $variables ) ) {
return $not_found;
}
$val = $variables[ $matches[2] ];
$maybe_units = '';
// check if we need to add units after value
if ( ! empty( $matches[6] ) ) {
$maybe_units = $matches[6];
}
// check if we search for array val
if ( ! empty( $matches[4] ) && is_array( $val ) && isset( $val[ $matches[4] ] ) ) {
return $val[ $matches[4] ] . $maybe_units;
}
if ( ! is_array( $val ) ) {
return $val . $maybe_units;
} else {
return $matches[0];
}
}
/**
* Callback function to replace CSS functions
*
* @since 1.0.0
* @param [string] $matches founded dunction.
*/
function replace_func( $matches ) {
$not_found = '/* Function does not exist */';
// check if functions name found
if ( empty( $matches[2] ) ) {
return $not_found;
}
$functions = $this->get_css_functions();
// check if function exists and is not CSS-reserved word
if ( ! array_key_exists( $matches[2], $functions ) ) {
if ( is_array( $this->css_reserved ) && in_array( $matches[2], $this->css_reserved ) ) {
return $matches[0];
} else {
return $not_found;
}
}
$function = $functions[ $matches[2] ];
$args = isset( $matches[3] ) ? $matches[3] : array();
if ( empty( $args ) ) {
$result = call_user_func( $function );
return $result;
}
if ( 'font_family' == $matches[2] ) {
$result = call_user_func( $function, $args );
return $result;
}
$args = str_replace( ' ', '', $args );
$args = explode( ',', $args );
if ( ! is_callable( $function ) ) {
return $not_found;
}
if ( ! empty( $args ) ) {
$args = array_map( array( $this, 'prepare_args' ), $args );
}
$result = call_user_func_array( $function, $args );
return $result;
}
/**
* Filter user function arguments
*
* @since 1.0.0
*/
function prepare_args( $item ) {
$name = str_replace( '$', '', $item );
$variables = $this->get_css_varaibles();
if ( ! array_key_exists( $name, $variables ) ) {
return $item;
}
return $variables[ $name ];
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,282 @@
<?php
/**
* Dynamic CSS collector class.
*
* @package Cherry_Framework
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Dynamic_Css_Collector' ) ) {
/**
* Define Cherry_Dynamic_Css_Collector class
*/
class Cherry_Dynamic_Css_Collector {
/**
* A reference to an instance of this class.
*
* @since 1.2.0
* @var object
*/
private static $instance = null;
/**
* Array with sorted css
*
* @var array
*/
public static $sorted_css = array();
/**
* Apropriate JS handle name
*
* @var string
*/
public static $js_handle = 'cherry-js-core';
/**
* Passed handler file content
*
* @var string
*/
public static $handler_file = null;
/**
* Set handler file on construct
*/
function __construct( $handler_file = null ) {
self::$handler_file = $handler_file;
}
/**
* Add new style to collector
*
* @param string $selector CSS selector to add styles for.
* @param array $style Styles array to add.
* @param array $media Media breakpoints.
* @return void
*/
public function add_style( $selector, $style = array(), $media = array() ) {
$this->prepare_rule(
$selector,
array(
'style' => $style,
'media' => $media,
)
);
}
/**
* Return JS handle name
*
* @return string
*/
public function get_handle() {
return apply_filters( 'cherry_dynamic_css_collector_handle', self::$js_handle );
}
/**
* Add inline JS handler
*
* @return void
*/
public function add_js_handler() {
if ( ! self::$handler_file ) {
return;
}
wp_add_inline_script( $this->get_handle(), self::$handler_file );
}
/**
* Print grabbed CSS
*
* @return void
*/
public function print_style() {
self::$sorted_css = apply_filters(
'cherry_dynamic_css_collected_styles',
self::$sorted_css
);
if ( empty( self::$sorted_css ) || ! is_array( self::$sorted_css ) ) {
return;
}
ob_start();
do_action( 'cherry_dynamic_css_before_print_collected' );
array_walk( self::$sorted_css, array( $this, 'print_breakpoint' ) );
do_action( 'cherry_dynamic_css_after_print_collected' );
$styles = ob_get_clean();
$localize_var = apply_filters( 'cherry_dynamic_css_collector_localize_object', array(
'type' => 'text/css',
'title' => 'cherry-collected-dynamic-style',
'css' => $styles,
) );
wp_localize_script( $this->get_handle(), 'CherryCollectedCSS', $localize_var );
}
/**
* Print single breakpoint
*
* @param array $rules Rules array.
* @param string $breakpoint Breakpoint name.
* @return void
*/
public function print_breakpoint( $rules, $breakpoint ) {
if ( empty( $rules ) ) {
return;
}
if ( 'all' !== $breakpoint ) {
echo '@' . esc_attr( $breakpoint ) . ' {';
}
do_action( 'cherry_dynamic_css_breakpoint_start', $breakpoint );
array_walk( $rules, array( $this, 'print_rules' ) );
do_action( 'cherry_dynamic_css_breakpoint_end', $breakpoint );
if ( 'all' !== $breakpoint ) {
echo '}';
}
}
/**
* Print rules for selector.
*
* @param array $rule Single rule.
* @param string $selector Selector name.
* @return void
*/
public function print_rules( $rule, $selector ) {
echo esc_attr( $selector ) . ' {';
do_action( 'cherry_dynamic_css_rule_start', $selector );
array_walk( $rule, array( $this, 'print_property' ) );
do_action( 'cherry_dynamic_css_rule_end', $selector );
echo '}';
}
/**
* Print single rule.
*
* @param string $value Property value.
* @param string $name Property name.
* @return void
*/
public function print_property( $value, $name ) {
printf( '%1$s:%2$s; ', $name, $value );
}
/**
* Print passed rule.
*
* @param string $selector Selector name.
* @param array $rule CSS rule data.
* @return void|bool
*/
public function prepare_rule( $selector, $rule ) {
$rule = array_merge( array(
'style' => array(),
'media' => array(),
), $rule );
if ( empty( $rule['style'] ) ) {
return false;
}
$breakpoint = $this->breakpoint_name( $rule['media'] );
if ( ! isset( self::$sorted_css[ $breakpoint ] ) ) {
self::$sorted_css[ $breakpoint ] = array();
}
if ( isset( self::$sorted_css[ $breakpoint ][ $selector ] ) ) {
self::$sorted_css[ $breakpoint ][ $selector ] = array_merge(
self::$sorted_css[ $breakpoint ][ $selector ],
$rule['style']
);
} else {
self::$sorted_css[ $breakpoint ][ $selector ] = $rule['style'];
}
}
/**
* Generate media rule name
*
* @param array $media Media breakpoints.
* @return string
*/
public function breakpoint_name( $media ) {
$has_media = false;
$min = '';
$max = '';
$sep = '';
if ( ! empty( $media['min'] ) ) {
$has_media = true;
$min = sprintf( '(min-width: %1$s)', esc_attr( $media['min'] ) );
}
if ( ! empty( $media['max'] ) ) {
$sep = true === $has_media ? ' and ' : '';
$has_media = true;
$max = sprintf( '(max-width: %1$s)', esc_attr( $media['max'] ) );
}
if ( ! $has_media ) {
return 'all';
}
return sprintf( 'media %1$s%3$s%2$s', $min, $max, $sep );
}
/**
* Returns the instance.
*
* @since 1.2.0
* @return object
*/
public static function get_instance( $handler_file = null ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $handler_file );
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,858 @@
<?php
/**
* Define CSS functions callbacks
*
* @package package_name
* @author Cherry Team
* @license GPL-3.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Dynamic_Css_Utilities' ) ) {
/**
* Define Cherry_Dynamic_Css_Utilities class
*/
class Cherry_Dynamic_Css_Utilities {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Make passed color darken.
*
* @since 1.0.0
* @param [string] $color HEX or RGB(A) color value.
* @param [float] $darken Darken percent (0-100).
* @return string Processed color.
*/
public function color_darken( $color, $darken = 0 ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, $darken );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$a = $prepared_data['a'];
$percent = $prepared_data['percent'];
// Calc darken vals.
$r = round( $r - 255 * $percent, 0 );
$g = round( $g - 255 * $percent, 0 );
$b = round( $b - 255 * $percent, 0 );
$r = $r < 0 ? 0 : $r;
$g = $g < 0 ? 0 : $g;
$b = $b < 0 ? 0 : $b;
if ( false !== $a ) {
return sprintf( 'rgba(%s,%s,%s,%s)', $r, $g, $b, $a );
} else {
return sprintf( 'rgb(%s,%s,%s)', $r, $g, $b );
}
}
/**
* Make passed color lighten.
*
* @since 1.0.0
* @param [string] $color HEX or RGB(A) color value.
* @param [float] $lighten Lighten percent (0-100).
* @return string Processed color.
*/
public function color_lighten( $color, $lighten = 0 ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, $lighten );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$a = $prepared_data['a'];
$percent = $prepared_data['percent'];
// Calc lighten vals
$r = round( $r + 255 * $percent, 0 );
$g = round( $g + 255 * $percent, 0 );
$b = round( $b + 255 * $percent, 0 );
$r = $r > 255 ? 255 : $r;
$g = $g > 255 ? 255 : $g;
$b = $b > 255 ? 255 : $b;
if ( false !== $a ) {
return sprintf( 'rgba(%s,%s,%s,%s)', $r, $g, $b, $a );
} else {
return sprintf( 'rgb(%s,%s,%s)', $r, $g, $b );
}
}
/**
* Convert passed color into RGBa with passed opacity.
*
* @since 1.0.0
* @param [string] $color Color to convert.
* @param [integer] $opacity Opacity.
* @return string
*/
public function color_alpha( $color, $opacity = 100 ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, 100 );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$a = intval( $opacity ) / 100;
return sprintf( 'rgba(%s,%s,%s,%s)', $r, $g, $b, $a );
}
/**
* Select contrast color for passed from 2 proposed.
*
* 1st proposed color must be light - it will selected if passed color is dark,
* 2nd selected if passed is light, so it must be darken.
*
* @since 1.0.0
* @param [string] $color Color to get contrast for.
* @param [string] $if_dark Return this if we had dark color.
* @param [string] $if_light Return this if we had light color.
* @return string Color.
*/
public function color_contrast( $color, $if_dark = '#ffffff', $if_light = '#000000' ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, 100 );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$luminance = 0.299 * $r + 0.587 * $g + 0.114 * $b;
if ( $luminance >= 128 ) {
return $if_light;
} else {
return $if_dark;
}
}
/**
* Prepare color to modify.
*
* Bring passed color and change percent to array
* with R, G, B color values, opacity (if provided)
* and change percentage.
*
* @since 1.0.0
* @param [string] $color HEX or RGB(A) color value.
* @param [float] $percent Modify percent (0-100).
* @return array Prepared color and modify percent.
*/
public function prepare_color_mod( $color, $percent = 0 ) {
$is_rgba = ( false !== strpos( $color, 'rgba' ) ) ? true : false;
$is_rgb = ( false !== strpos( $color, 'rgb' ) && false === $is_rgba ) ? true : false;
$is_hex = ( false === $is_rgba && false === $is_rgb ) ? true : false;
$percent = round( (double) $percent / 100, 4 );
if ( $is_hex && '#' == $color[0] ) {
$color = substr( $color, 1 );
}
// Prepare hex color.
if ( $is_hex && strlen( $color ) == 6 ) {
list( $r, $g, $b ) = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
} elseif ( $is_hex && strlen( $color ) == 3 ) {
list( $r, $g, $b ) = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
} elseif ( $is_hex ) {
return false;
}
if ( $is_hex ) {
$r = hexdec( $r );
$g = hexdec( $g );
$b = hexdec( $b );
}
$color = str_replace( ' ', '', $color );
// Prepare RGBA.
if ( $is_rgba ) {
preg_match( '/rgba\((.*)\)/', $color, $matches );
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
return false;
}
list( $r, $g, $b, $a ) = explode( ',', $matches[1] );
}
// Prepare RGB.
if ( $is_rgb ) {
preg_match( '/rgb\((.*)\)/', $color, $matches );
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
return false;
}
list( $r, $g, $b ) = explode( ',', $matches[1] );
}
$result = array(
'r' => $r,
'g' => $g,
'b' => $b,
'a' => isset( $a ) ? $a : false,
'percent' => $percent,
);
return $result;
}
/**
* Get background-image CSS property CSS by url.
*
* @param [string] $url url-value.
* @return string
*/
public function background_url( $url = '' ) {
if ( empty( $url ) ) {
return;
}
$result = 'background-image: url(' . esc_url( $url ) . ')';
return $result;
}
/**
* Get background CSS by bg data from options and selector.
* If passed multiplie images - returns retina ready CSS.
*
* @since 1.0.0
* @param [string] $selector CSS selector to apply bg for.
* @param [array] $data data-array from options.
* @return string
*/
public function get_background_css( $selector, $data ) {
if ( ! $selector ) {
return;
}
if ( ! is_array( $data ) ) {
return;
}
if ( empty( $data['image'] ) && empty( $data['color'] ) ) {
return;
}
$standard_bg = cherry_prepare_background( $data );
if ( empty( $data['image'] ) ) {
$standard_bg .= 'background-image:none;';
return $selector . '{' . $standard_bg . '}';
}
$images = explode( ',', $data['image'] );
$property_format = "%1$s {background-image: url(%2$s);%3$s}";
if ( 1 == count( $images ) && wp_attachment_is_image( $images[0] ) ) {
$img = wp_get_attachment_image_src( $images[0], 'full' );
$result = sprintf( $property_format, $selector, $img[0], $standard_bg );
return $result;
}
$img1x = null;
$img2x = null;
$width1x = 0;
$count = 2;
for ( $i = 0; $i < $count; $i++ ) {
if ( ( ! isset( $images[ $i ] ) ) || ( ! wp_attachment_is_image( $images[ $i ] ) ) ) {
continue;
}
$img = wp_get_attachment_image_src( $images[ $i ], 'full' );
if ( ! is_array( $img ) ) {
continue;
}
$img_url = $img[0];
$img_width = intval( $img[1] );
if ( null == $img1x ) {
$img1x = $img_url;
$img2x = $img_url;
$width1x = $img_width;
} elseif ( $img_width > $width1x ) {
$img2x = $img_url;
} else {
$img1x = $img_url;
}
}
$bg1 = sprintf( $property_format, $selector, $img1x, $standard_bg );
$bg2 = sprintf( $property_format, $selector, $img2x, '' );
$result = $bg1 . ' @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {' . $bg2 . '}';
return $result;
}
/**
* Sanitizes a hex color.
*
* Always adds hash to color use `sanitize_hex_color` if exist.
*
* @since 1.0.0
* @param [string] $color Maybe HEX color.
* @return string|null Sanitized color.
*/
public function sanitize_hex_color( $color ) {
$color = ltrim( $color, '#' );
$color = '#' . $color;
if ( '' === $color ) {
return '';
}
if ( function_exists( 'sanitize_hex_color' ) ) {
return sanitize_hex_color( $color );
}
// 3 or 6 hex digits, or the empty string.
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}
return null;
}
/**
* Implode background properties array into CSS string.
*
* @since 1.0.0
* @param [array] $data Background data-array.
* @return string Set of background rules.
*/
public function prepare_background( $data ) {
if ( ! is_array( $data ) ) {
return;
}
unset( $data['image'] );
$result = '';
$format = 'background-%s:%s;';
foreach ( $data as $prop => $value ) {
if ( ! $value ) {
continue;
}
switch ( $prop ) {
case 'color':
$value = $this->sanitize_hex_color( $value );
break;
case 'position':
$value = str_replace( '-', ' ', $value );
break;
}
$result .= sprintf( $format, $prop, $value );
}
return $result;
}
/**
* Implode typography data array from options into CSS string.
*
* @since 1.0.0
* @param [array] $data Typography parameters array from options.
* @param [array] $mod Optional parameter - pass function name and arg to modify values inside typography array.
* @return string Font, letter-spacing, text-align, color CSS properties string.
*/
public function cherry_get_typography_css( $data, $mod = array() ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return;
}
$defaults = array(
'family' => '',
'style' => '',
'color' => '',
'size' => '',
'lineheight' => '',
'letterspacing' => '',
'align' => '',
);
$data = wp_parse_args( $data, $defaults );
$result = array();
if ( '' !== $data['letterspacing'] ) {
$units = '0' != $data['letterspacing'] ? 'px' : '';
$result[] = 'letter-spacing:' . $data['letterspacing'] . $units;
}
if ( 'notdefined' != $data['align'] ) {
$result[] = 'text-align:' . $data['align'];
}
if ( '' != $data['color'] ) {
$color = $this->sanitize_hex_color( $data['color'] );
if ( 1 < count( $mod ) && ( in_array( $mod[0], array( 'cherry_colors_lighten', 'cherry_colors_darken' ) ) ) ) {
$color = $mod[0]( $color, $mod[1] );
}
$result[] = 'color:' . $color;
}
$family = stripcslashes( $data['family'] );
$family = explode( ',', $family );
array_walk( $family, array( $this, 'typography_prepare_family' ) );
$family[] = ! empty( $data['category'] ) ? $data['category'] : 'sans-serif';
$family = array_unique( $family );
$font_style = false;
$font_weight = false;
$font_size = $data['size'] . 'px';
$line_height = $data['lineheight'] . 'px';
$font_family = implode( ', ', $family );
preg_match( '/^(\d*)(\w*)/i', $data['style'], $matches );
if ( is_array( $matches ) ) {
$font_style = ( 'regular' != $matches[2] ) ? $matches[2] : false;
$font_weight = $matches[1];
}
$font = array(
$font_style,
$font_weight,
$font_size . '/' . $line_height,
$font_family,
);
$font = implode( ' ', array_filter( $font ) );
$result[] = 'font:' . ltrim( $font );
$result = implode( ';', $result ) . ';';
return $result;
}
/**
* Prepare font family for passing into typography function.
*
* @since 1.0.0
* @param [string] $item Array item.
* @param [int] $index Array item index.
* @return void
*/
public function typography_prepare_family( &$item, $index ) {
$item = trim( $item );
if ( strpos( $item, ' ' ) ) {
$item = '"' . $item . '"';
}
}
/**
* Get box model CSS from layout editor option.
*
* @since 1.0.0
* @param [array] $data Layout parameters array from options.
* @param [array] $mod Optional parameter - pass function name and arg to modify values inside layout array.
* @return string Indents, border etc.
*/
public function cherry_get_box_model_css( $data, $mod = array() ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return;
}
$defaults = array(
'position' => array(),
'margin' => array(),
'border' => array(),
'padding' => array(),
'container' => array(),
);
$box_defaults = array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
$data = wp_parse_args( $data, $defaults );
$result = '';
// Prepare postion
$data['position'] = array_filter( $data['position'] );
if ( ! empty( $data['position'] ) ) {
$data['position'] = array_intersect_key( $data['position'], $box_defaults );
$parser_data = array(
'prefix' => '',
'allowed' => $box_defaults,
);
array_walk( $data['position'], 'cherry_prepare_box_item', $parser_data );
$result .= implode( ';', array_filter( $data['position'] ) ) . ';';
}
// Prepare indents.
$result .= cherry_prepare_css_indents( $data['margin'], 'margin' );
$result .= cherry_prepare_css_indents( $data['padding'], 'padding' );
// Prepare borders
if ( ! empty( $data['border'] ) ) {
$border_style = ! empty( $data['border']['style'] ) ? $data['border']['style'] : '';
$border_color = ! empty( $data['border']['color'] ) ? $data['border']['color'] : '';
$border_radius = ! empty( $data['border']['radius'] ) ? $data['border']['radius'] : '';
if ( '' != $border_radius ) {
$result .= 'border-radius:' . $border_radius . ';';
}
$border_format = 'border-%1$s:%2$s %3$s %4$s;';
foreach ( $data['border'] as $property => $value ) {
if ( ! array_key_exists( $property, $box_defaults ) ) {
continue;
}
if ( empty( $value ) ) {
continue;
}
$result .= sprintf(
$border_format,
$property, $value, $border_style, $border_color
);
}
}
// Prepare dimensions.
if ( ! empty( $data['container']['width'] ) ) {
$result .= 'width:' . $data['container']['width'] . ';';
}
if ( ! empty( $data['container']['height'] ) ) {
$result .= 'height:' . $data['container']['height'] . ';';
}
return $result;
}
/**
* Service function to grab CSS indents from data array into string.
*
* @since 1.0.0
* @param [array] $data data-array.
* @param [string] $property CSS property.
* @return string
*/
public function cherry_prepare_css_indents( $data, $property ) {
if ( empty( $data ) ) {
return;
}
$box_defaults = array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
$data = array_intersect_key( $data, $box_defaults );
$data = array_filter( $data );
if ( 4 == count( $data ) ) {
$result = $property . ':' . implode( ' ', $data ) . ';';
return $result;
}
$parser_data = array(
'prefix' => $property,
'allowed' => $box_defaults,
);
array_walk( $data, 'cherry_prepare_box_item', $parser_data );
$result = implode( ';', array_filter( $data ) ) . ';';
return $result;
}
/**
* Service callback function for.
*
* @since 1.0.0
* @param [string] $item Position value.
* @param [string] $key Position key.
* @param [array] $data Array of allowed positions and property prefix.
* @return void
*/
public function cherry_prepare_box_item( &$item, $key, $data ) {
if ( ! array_key_exists( $key, $data['allowed'] ) ) {
$item = false;
return;
}
if ( empty( $item ) ) {
$item = false;
return;
}
$prefix = '';
if ( ! empty( $data['prefix'] ) ) {
$prefix = $data['prefix'] . '-';
}
$item = $prefix . $key . ':' . $item;
}
/**
* Prepare font family to the using in CSS.
*
* @since 1.0.1
* @param [string] $font_family Font name.
* @return string
*/
public function typography_font_family( $font_family ) {
$font_family = trim( $font_family );
$family_args = explode( ',', $font_family );
$names = '';
$type = end( $family_args );
$type = trim( $type );
for ( $i = 0; $i < count( $family_args ) - 1; $i++ ) {
if ( strpos( $family_args[ $i ], ' ' ) ) {
$names .= "'" . $family_args[ $i ] . "',";
} else {
$names .= $family_args[ $i ] . ',';
}
}
return sprintf( '%1$s, %2$s', trim( $names, ',' ), $type );
}
/**
* Make float size.
*
* @since 1.0.0
* @param [double] $size Font size.
* @param [string] $operation Arithmetic operator (multiple, addition).
* @param [string] $func Function name (floor, ceil, round, abs).
* @param [double] $percent Font size in percent.
* @return double Size.
*/
public function typography_size( $size, $operation = ' ', $func = 'round', $percent ) {
if ( ! $size ) {
return false;
}
switch ( $operation ) {
case 'multiple' :
$size = (double) $size * (double) $percent;
break;
case 'addition' :
$size = (double) $size + (double) $percent;
break;
}
switch ( $func ) {
case 'floor' :
$size = floor( $size );
break;
case 'ceil' :
$size = ceil( $size );
break;
case 'round' :
$size = round( $size );
break;
case 'abs' :
$size = abs( $size );
break;
}
return $size;
}
/**
* Build a CSS-rule.
*
* @since 1.0.0
* @param [string|int] $value CSS-proterty value.
* @param [string] $rule CSS-proterty name.
* @return string CSS-rule.
*/
public function empty_value( $value, $rule ) {
if ( '' == $value || 'notdefined' == $value ) {
return;
}
echo $rule . ': ' . $value;
if ( is_numeric( $value ) ) {
echo 'px; ';
} else {
echo '; ';
}
}
/**
* Set element emphasis.
*
* @since 1.0.0
* @param [string] $parent Parent selector.
* @param [string] $color Color.
* @param [string] $property To define.
*/
public function element_emphasis( $parent, $color, $property ) {
$result = $parent . ' {' . $property . ':' . $color . ';}';
$result .= $parent . ':hover {' . $property . ':' . $this->color_darken( $color, 10 ) . ';}';
return $result;
}
/**
* Return width value for container.
*
* @since 1.0.0
* @param [int] $container_width A container width value.
* @param [int] $element_width Some-block (parent-block for container) width value.
* @return int Width value.
*/
public function container_width_compare( $container_width, $element_width ) {
return ( $container_width > $element_width ) ? $element_width : $container_width;
}
/**
* Sum of $a and $b.
*
* @since 1.0.0
* @param [int] $a Operand 1.
* @param [int] $b Operand 2.
* @return int Addition.
*/
public function simple_sum( $a, $b ) {
return intval( $a ) + intval( $b );
}
/**
* Difference of $a and $b.
*
* @since 1.0.0
* @param [int] $a Operand 1.
* @param [int] $b Operand 2.
* @return int Subtraction.
*/
public function simple_diff( $a, $b ) {
return intval( $a ) - intval( $b );
}
/**
* Retrieve a width to swith on mobile menu from.
*
* @since 1.0.0
* @return int Width value.
*/
public function menu_toogle_endpoint() {
/**
* Filters a value when mobile menu switched.
*
* @since 1.0.0
* @param int $value Width value.
*/
return apply_filters( 'cherry_menu_toogle_endpoint', 600 );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,374 @@
<?php
/**
* Module Name: Google Fonts Loader
* Description: Enqueue Google fonts
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Google_Fonts_Loader' ) ) {
/**
* Google fonts loader main class
*/
class Cherry_Google_Fonts_Loader {
/**
* Module slug.
*
* @var string
*/
public $module_slug = 'cherry-google-fonts-loader';
/**
* Module arguments
*
* @var array
*/
public $args = array();
/**
* Core instance
*
* @var object
*/
public $core = null;
/**
* Define fonts server URL
*
* @var string
*/
public $fonts_host = '//fonts.googleapis.com/css';
/**
* Google fonts set
*
* @var array
*/
public $google_fonts = null;
/**
* Array of stored google fonts data
*
* @var array
*/
public $fonts_data = array();
/**
* Constructor for the class
*/
function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args( $args, array(
'options' => array(),
) );
$this->fonts_host = apply_filters( 'cherry_google_fonts_cdn', $this->fonts_host );
add_action( 'customize_preview_init', array( $this, 'reset_fonts_cache' ) );
add_action( 'customize_save_after', array( $this, 'reset_fonts_cache' ) );
add_action( 'switch_theme', array( $this, 'reset_fonts_cache' ) );
if ( is_admin() ) {
return;
}
add_action( 'wp_enqueue_scripts', array( $this, 'prepare_fonts' ) );
}
/**
* Get fonts data and enqueue URL
*
* @since 1.0.0
*/
public function prepare_fonts() {
$font_url = $this->get_fonts_url();
wp_enqueue_style( 'cherry-google-fonts-' . $this->args['prefix'], $font_url );
}
/**
* Returns transient key.
*
* @return [type] [description]
*/
public function transient_key() {
return 'cherry_google_fonts_url_' . $this->args['prefix'];
}
/**
* Return theme Google fonts URL to enqueue it
*
* @since 1.0.0
* @return string
*/
public function get_fonts_url() {
$font_url = get_transient( $this->transient_key() );
if ( ! $font_url ) {
// Get typography options list
$options_set = $this->get_options_set();
// build Google fonts data array
foreach ( $options_set as $option ) {
$this->add_font( $option );
}
$font_url = $this->build_fonts_url();
if ( false == $font_url ) {
return;
}
global $wp_customize;
if ( ! isset( $wp_customize ) ) {
set_transient( $this->transient_key(), $font_url, WEEK_IN_SECONDS );
}
}
return $font_url;
}
/**
* Get options set from module arguments
*
* @return array
*/
public function get_options_set() {
return $this->args['options'];
}
/**
* Get current setting by name
*
* @since 1.0.0
* @return mixed
*/
public function get_setting( $name ) {
$type = $this->args['type'];
if ( 'theme_mod' == $type ) {
$setting = get_theme_mod( $name );
return $setting;
}
if ( true != $this->args['single'] ) {
$setting = get_option( $name );
return $setting;
}
$settings = get_option( $this->args['prefix'] );
if ( ! empty( $settings ) && isset( $settings[ $name ] ) ) {
return $settings[ $name ];
}
return false;
}
/**
* Build Google fonts stylesheet URL from stored data
*
* @since 1.0.0
*/
public function build_fonts_url() {
$font_families = array();
$subsets = array();
if ( empty( $this->fonts_data ) ) {
return false;
}
foreach ( $this->fonts_data as $family => $data ) {
$styles = implode( ',', array_unique( array_filter( $data['style'] ) ) );
$font_families[] = $family . ':' . $styles;
$subsets = array_merge( $subsets, $data['character'] );
}
$subsets = array_unique( array_filter( $subsets ) );
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( implode( ',', $subsets ) ),
);
$fonts_url = add_query_arg( $query_args, $this->fonts_host );
return $fonts_url;
}
/**
* Get single typography option value from database and store it in object property
*
* @since 1.0.0
* @param [type] $font option name to get from database.
*/
public function add_font( $font ) {
$font = wp_parse_args( $font, array(
'family' => '',
'style' => 'normal',
'weight' => '400',
'charset' => 'latin',
) );
$family = $this->get_setting( $font['family'] );
$family = explode( ',', $family );
$family = trim( $family[0], "'" );
if ( ! $this->is_google_font( $family ) ) {
return;
}
$load_style = $this->get_setting( $font['weight'] );
$font_style = $this->get_setting( $font['style'] );
if ( 'italic' === $font_style ) {
$load_style .= $font_style;
}
if ( ! isset( $this->fonts_data[ $family ] ) ) {
$this->fonts_data[ $family ] = array(
'style' => array( $load_style ),
'character' => array( $this->get_setting( $font['charset'] ) ),
);
} else {
$this->fonts_data[ $family ] = array(
'style' => $this->add_font_prop(
$load_style,
$this->fonts_data[ $family ]['style']
),
'character' => $this->add_font_prop(
$this->get_setting( $font['charset'] ),
$this->fonts_data[ $family ]['character']
),
);
}
}
/**
* Add new font property to existaing properties array
*
* @since 1.0.0
* @param [type] $new property to add.
* @param array $existing existing properties.
*/
public function add_font_prop( $new, $existing ) {
if ( ! is_array( $existing ) ) {
return array( $new );
}
if ( ! in_array( $new, $existing ) ) {
$existing[] = $new;
}
return $existing;
}
/**
* Check if selected font is google font
*
* @since 1.0.0
* @param array $font_family font family to check.
* @return boolean
*/
public function is_google_font( $font_family ) {
$google_fonts = $this->get_google_fonts();
if ( empty( $google_fonts ) ) {
$customizer = isset( $this->core->modules['cherry-customizer'] ) ? $this->core->modules['cherry-customizer'] : false;
if ( ! $customizer ) {
return false;
}
$customizer->init_fonts();
$google_fonts = $this->get_google_fonts();
if ( empty( $google_fonts ) ) {
return false;
}
}
$font_family = explode( ',', $font_family );
$font_family = trim( $font_family[0], "'" );
foreach ( $google_fonts as $font ) {
if ( $font_family === $font['family'] ) {
return true;
}
}
return false;
}
/**
* Get google fonts array
*
* @since 1.0.0
* @return array
*/
public function get_google_fonts() {
if ( null === $this->google_fonts ) {
$this->google_fonts = get_option( 'cherry_customiser_fonts_google', null );
}
return $this->google_fonts;
}
/**
* Reset fonts cache
*
* @since 1.0.0
*/
public function reset_fonts_cache() {
delete_transient( $this->transient_key() );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1 @@
.cherry-handler-notice{background:#23282d;position:fixed;margin:5px 0;box-shadow:1px 1px 5px rgba(0,0,0,0.2);box-sizing:border-box;padding:8px 15px 8px 8px;min-width:200px;overflow:hidden;color:#fff;z-index:999;border-radius:2px;-webkit-transition:all 250ms cubic-bezier(0.85, 0.04, 1, 1);transition:all 250ms cubic-bezier(0.85, 0.04, 1, 1)}.cherry-handler-notice span.dashicons{position:relative;margin-right:10px}.cherry-handler-notice span.dashicons:before{position:absolute;font-size:30px;left:-6px;top:-4px}.cherry-handler-notice.success-notice span.dashicons{color:#48c569}.cherry-handler-notice.success-notice span.dashicons:before{content:"\f147"}.cherry-handler-notice.success-notice .inner b{color:#48c569}.cherry-handler-notice.info-notice span.dashicons{color:#faa730}.cherry-handler-notice.info-notice span.dashicons:before{content:"\f534"}.cherry-handler-notice.info-notice .inner b{color:#faa730}.cherry-handler-notice.error-notice span.dashicons{color:#e54343}.cherry-handler-notice.error-notice span.dashicons:before{content:"\f158"}.cherry-handler-notice.show-state{-webkit-transition:all 500ms cubic-bezier(0.1, 0.67, 0.26, 1);transition:all 500ms cubic-bezier(0.1, 0.67, 0.26, 1)}.cherry-handler-notice .inner{display:inline-block}

View File

@@ -0,0 +1,309 @@
( function( $, CherryJsCore ) {
'use strict';
/**
* CherryAjaxHandler class
*
* @param {object} options Handler options
*/
CherryJsCore.utilites.namespace( 'CherryAjaxHandler' );
CherryJsCore.CherryAjaxHandler = function( options ) {
/**
* General default settings
*
* @type {Object}
*/
var self = this,
settings = {
'handlerId': '',
'cache': false,
'processData': true,
'url': '',
'async': false,
'beforeSendCallback': function() {},
'errorCallback': function() {},
'successCallback': function() {},
'completeCallback': function() {}
};
/**
* Checking options, settings and options merging
*
*/
if ( options ) {
$.extend( settings, options );
}
/**
* Check if handlerId ready to using
*
*/
if ( ! window[ settings.handlerId ] ) {
if ( window.console ) {
window.console.warn( 'Handler id not found' );
}
return false;
}
/**
* Set handler settings from localized global variable
*
* @type {Object}
*/
self.handlerSettings = window[ settings.handlerId ] || {};
/**
* Ajax request instance
*
* @type {Object}
*/
self.ajaxRequest = null;
/**
* Ajax processing state
*
* @type {Boolean}
*/
self.ajaxProcessing = false;
/**
* Set ajax request data
*
* @type {Object}
*/
self.data = {
'action': self.handlerSettings.action,
'nonce': self.handlerSettings.nonce
};
/**
* Check ajax url is empty
*/
if ( '' === settings.url ) {
// Check public request
if ( 'false' === self.handlerSettings.is_public ) {
settings.url = window.ajaxurl;
} else {
settings.url = window.cherryHandlerAjaxUrl.ajax_url;
}
}
/**
* Init ajax request
*
* @return {Void}
*/
self.send = function() {
if ( self.ajaxProcessing ) {
CherryJsCore.cherryHandlerUtils.noticeCreate( 'error-notice', self.handlerSettings.sys_messages.wait_processing, self.handlerSettings.is_public );
}
self.ajaxProcessing = true;
self.ajaxRequest = jQuery.ajax( {
type: self.handlerSettings.type,
url: settings.url,
data: self.data,
cache: settings.cache,
dataType: self.handlerSettings.data_type,
processData: settings.processData,
beforeSend: function( jqXHR, ajaxSettings ) {
if ( null !== self.ajaxRequest && ! settings.async ) {
self.ajaxRequest.abort();
}
if ( settings.beforeSendCallback && 'function' === typeof( settings.beforeSendCallback ) ) {
settings.beforeSendCallback( jqXHR, ajaxSettings );
}
},
error: function( jqXHR, textStatus, errorThrown ) {
$( document ).trigger( {
type: 'cherry-ajax-handler-error',
jqXHR: jqXHR,
textStatus: textStatus,
errorThrown: errorThrown
} );
if ( settings.errorCallback && 'function' === typeof( settings.errorCallback ) ) {
settings.errorCallback( jqXHR, textStatus, errorThrown );
}
},
success: function( data, textStatus, jqXHR ) {
self.ajaxProcessing = false;
$( document ).trigger( {
type: 'cherry-ajax-handler-success',
response: data,
jqXHR: jqXHR,
textStatus: textStatus
} );
if ( settings.successCallback && 'function' === typeof( settings.successCallback ) ) {
settings.successCallback( data, textStatus, jqXHR );
}
CherryJsCore.cherryHandlerUtils.noticeCreate( data.type, data.message, self.handlerSettings.is_public );
},
complete: function( jqXHR, textStatus ) {
$( document ).trigger( {
type: 'cherry-ajax-handler-complete',
jqXHR: jqXHR,
textStatus: textStatus
} );
if ( settings.completeCallback && 'function' === typeof( settings.completeCallback ) ) {
settings.completeCallback( jqXHR, textStatus );
}
}
} );
};
/**
* Send data ajax request
*
* @param {Object} data User data
* @return {Void}
*/
self.sendData = function( data ) {
var sendData = data || {};
self.data = {
'action': self.handlerSettings.action,
'nonce': self.handlerSettings.nonce,
'data': sendData
};
self.send();
};
/**
* Send form serialized data
* @param {String} formId Form selector
* @return {Void}
*/
self.sendFormData = function( formId ) {
var form = $( formId ),
data;
data = CherryJsCore.cherryHandlerUtils.serializeObject( form );
self.sendData( data );
};
};
CherryJsCore.utilites.namespace( 'cherryHandlerUtils' );
CherryJsCore.cherryHandlerUtils = {
/**
* Rendering notice message
*
* @param {String} type Message type
* @param {String} message Message content
* @return {Void}
*/
noticeCreate: function( type, message, isPublicPage ) {
var notice,
rightDelta = 0,
timeoutId,
isPublic = isPublicPage || false;
if ( ! message || 'true' === isPublic ) {
return false;
}
notice = $( '<div class="cherry-handler-notice ' + type + '"><span class="dashicons"></span><div class="inner">' + message + '</div></div>' );
$( 'body' ).prepend( notice );
reposition();
rightDelta = -1 * ( notice.outerWidth( true ) + 10 );
notice.css( { 'right': rightDelta } );
timeoutId = setTimeout( function() {
notice.css( { 'right': 10 } ).addClass( 'show-state' );
}, 100 );
timeoutId = setTimeout( function() {
rightDelta = -1 * ( notice.outerWidth( true ) + 10 );
notice.css( { right: rightDelta } ).removeClass( 'show-state' );
}, 4000 );
timeoutId = setTimeout( function() {
notice.remove();
clearTimeout( timeoutId );
}, 4500 );
function reposition() {
var topDelta = 100;
$( '.cherry-handler-notice' ).each( function() {
$( this ).css( { top: topDelta } );
topDelta += $( this ).outerHeight( true );
} );
}
},
/**
* Serialize form into
*
* @return {Object}
*/
serializeObject: function( form ) {
var self = this,
json = {},
pushCounters = {},
patterns = {
'validate': /^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_-]+)\])*$/,
'key': /[a-zA-Z0-9_-]+|(?=\[\])/g,
'push': /^$/,
'fixed': /^\d+$/,
'named': /^[a-zA-Z0-9_-]+$/
};
this.build = function( base, key, value ) {
base[ key ] = value;
return base;
};
this.push_counter = function( key ) {
if ( undefined === pushCounters[ key ] ) {
pushCounters[ key ] = 0;
}
return pushCounters[ key ]++;
};
$.each( form.serializeArray(), function() {
var k, keys, merge, reverseKey;
// Skip invalid keys
if ( ! patterns.validate.test( this.name ) ) {
return;
}
keys = this.name.match( patterns.key );
merge = this.value;
reverseKey = this.name;
while ( undefined !== ( k = keys.pop() ) ) {
// Adjust reverseKey
reverseKey = reverseKey.replace( new RegExp( '\\[' + k + '\\]$' ), '' );
// Push
if ( k.match( patterns.push ) ) {
merge = self.build( [], self.push_counter( reverseKey ), merge );
} else if ( k.match( patterns.fixed ) ) {
merge = self.build( [], k, merge );
} else if ( k.match( patterns.named ) ) {
merge = self.build( {}, k, merge );
}
}
json = $.extend( true, json, merge );
});
return json;
}
};
}( jQuery, window.CherryJsCore ) );

View File

@@ -0,0 +1 @@
!function(e,a){"use strict";a.utilites.namespace("CherryAjaxHandler"),a.CherryAjaxHandler=function(t){var n=this,r={handlerId:"",cache:!1,processData:!0,url:"",async:!1,beforeSendCallback:function(){},errorCallback:function(){},successCallback:function(){},completeCallback:function(){}};return t&&e.extend(r,t),window[r.handlerId]?(n.handlerSettings=window[r.handlerId]||{},n.ajaxRequest=null,n.ajaxProcessing=!1,n.data={action:n.handlerSettings.action,nonce:n.handlerSettings.nonce},""===r.url&&(r.url="false"===n.handlerSettings.is_public?window.ajaxurl:window.cherryHandlerAjaxUrl.ajax_url),n.send=function(){n.ajaxProcessing&&a.cherryHandlerUtils.noticeCreate("error-notice",n.handlerSettings.sys_messages.wait_processing,n.handlerSettings.is_public),n.ajaxProcessing=!0,n.ajaxRequest=jQuery.ajax({type:n.handlerSettings.type,url:r.url,data:n.data,cache:r.cache,dataType:n.handlerSettings.data_type,processData:r.processData,beforeSend:function(e,a){null===n.ajaxRequest||r.async||n.ajaxRequest.abort(),r.beforeSendCallback&&"function"==typeof r.beforeSendCallback&&r.beforeSendCallback(e,a)},error:function(a,t,n){e(document).trigger({type:"cherry-ajax-handler-error",jqXHR:a,textStatus:t,errorThrown:n}),r.errorCallback&&"function"==typeof r.errorCallback&&r.errorCallback(a,t,n)},success:function(t,c,s){n.ajaxProcessing=!1,e(document).trigger({type:"cherry-ajax-handler-success",response:t,jqXHR:s,textStatus:c}),r.successCallback&&"function"==typeof r.successCallback&&r.successCallback(t,c,s),a.cherryHandlerUtils.noticeCreate(t.type,t.message,n.handlerSettings.is_public)},complete:function(a,t){e(document).trigger({type:"cherry-ajax-handler-complete",jqXHR:a,textStatus:t}),r.completeCallback&&"function"==typeof r.completeCallback&&r.completeCallback(a,t)}})},n.sendData=function(e){var a=e||{};n.data={action:n.handlerSettings.action,nonce:n.handlerSettings.nonce,data:a},n.send()},void(n.sendFormData=function(t){var r,c=e(t);r=a.cherryHandlerUtils.serializeObject(c),n.sendData(r)})):(window.console&&window.console.warn("Handler id not found"),!1)},a.utilites.namespace("cherryHandlerUtils"),a.cherryHandlerUtils={noticeCreate:function(a,t,n){function r(){var a=100;e(".cherry-handler-notice").each(function(){e(this).css({top:a}),a+=e(this).outerHeight(!0)})}var c,s,i=0,o=n||!1;return t&&"true"!==o?(c=e('<div class="cherry-handler-notice '+a+'"><span class="dashicons"></span><div class="inner">'+t+"</div></div>"),e("body").prepend(c),r(),i=-1*(c.outerWidth(!0)+10),c.css({right:i}),s=setTimeout(function(){c.css({right:10}).addClass("show-state")},100),s=setTimeout(function(){i=-1*(c.outerWidth(!0)+10),c.css({right:i}).removeClass("show-state")},4e3),void(s=setTimeout(function(){c.remove(),clearTimeout(s)},4500))):!1},serializeObject:function(a){var t=this,n={},r={},c={validate:/^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_-]+)\])*$/,key:/[a-zA-Z0-9_-]+|(?=\[\])/g,push:/^$/,fixed:/^\d+$/,named:/^[a-zA-Z0-9_-]+$/};return this.build=function(e,a,t){return e[a]=t,e},this.push_counter=function(e){return void 0===r[e]&&(r[e]=0),r[e]++},e.each(a.serializeArray(),function(){var a,r,s,i;if(c.validate.test(this.name)){for(r=this.name.match(c.key),s=this.value,i=this.name;void 0!==(a=r.pop());)i=i.replace(new RegExp("\\["+a+"\\]$"),""),a.match(c.push)?s=t.build([],t.push_counter(i),s):a.match(c.fixed)?s=t.build([],a,s):a.match(c.named)&&(s=t.build({},a,s));n=e.extend(!0,n,s)}}),n}}}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,65 @@
.cherry-handler-notice{
background: #23282d;
position: fixed;
margin: 5px 0;
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
padding: 8px 15px 8px 8px;
min-width: 200px;
overflow: hidden;
color: #fff;
z-index: 999;
border-radius: 2px;
transition: all 250ms cubic-bezier(0.85, 0.04, 1, 1);
span.dashicons{
position: relative;
margin-right: 10px;
&:before{
position: absolute;
font-size: 30px;
left: -6px;
top: -4px;
}
}
&.success-notice{
span.dashicons{
color: #48c569;
&:before{
content: "\f147";
}
}
.inner{
b{
color: #48c569;
}
}
}
&.info-notice{
span.dashicons{
color: #faa730;
&:before{
content: "\f534";
}
}
.inner{
b{
color: #faa730;
}
}
}
&.error-notice{
span.dashicons{
color: #e54343;
&:before{
content: "\f158";
}
}
}
&.show-state{
-webkit-transition: all 500ms cubic-bezier(0.1, 0.67, 0.26, 1);
transition: all 500ms cubic-bezier(0.1, 0.67, 0.26, 1);
}
.inner{
display: inline-block;
}
}

View File

@@ -0,0 +1,246 @@
<?php
/**
* Module Name: Cherry handler
* Description: Initializes handlers
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Handler' ) ) {
/**
* Cherry_Handler class.
*
* @since 1.0.0
*/
class Cherry_Handler {
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $module_path;
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $settings = array(
'id' => '',
'action' => '',
'capability' => '',
'is_public' => false,
'callback' => '',
'type' => 'POST',
'data_type' => 'json',
'sys_messages' => array(),
);
/**
* Class constructor.
*
* @since 1.0.0
* @param object $core Core instance.
* @param array $args Class args.
*/
public function __construct( $core, $args = array() ) {
$this->settings['sys_messages'] = array(
'invalid_base_data' => esc_html__( 'Unable to process the request without nonce or server error', 'cherry-framework' ),
'no_right' => esc_html__( 'No right for this action', 'cherry-framework' ),
'invalid_nonce' => esc_html__( 'Stop CHEATING!!!', 'cherry-framework' ),
'access_is_allowed' => esc_html__( 'Access is allowed', 'cherry-framework' ),
'wait_processing' => esc_html__( 'Please wait, processing the previous request', 'cherry-framework' ),
);
$this->settings = array_merge( $this->settings, $args );
$this->core_version = $core->get_core_version();
$this->module_path = $args['module_path'];
if ( empty( $this->settings['id'] ) ) {
echo '<h3>ID is required attr</h3>';
return false;
}
if ( empty( $this->settings['action'] ) ) {
echo '<h3>Action is required attr</h3>';
return false;
}
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
add_action( 'wp_ajax_' . $this->settings['action'], array( $this, 'handler_init' ) );
// Public action check.
if ( filter_var( $this->settings['is_public'], FILTER_VALIDATE_BOOLEAN ) ) {
add_action( 'wp_ajax_nopriv_' . $this->settings['action'], array( $this, 'handler_init' ) );
}
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_print_scripts', array( $this, 'localize_script' ) );
}
/**
* Handler initialization
*
* @since 1.0.0
* @return void
*/
public function handler_init() {
$request_type = strtoupper( '_' . $this->settings['type'] );
if ( ! empty( $GLOBALS[ $request_type ] ) && array_key_exists( 'nonce', $GLOBALS[ $request_type ] ) ) {
$nonce = $GLOBALS[ $request_type ]['nonce'];
$nonce_action = ! empty( $this->settings['action'] ) ? $this->settings['action'] : 'cherry_ajax_nonce';
if ( ! wp_verify_nonce( $nonce, $nonce_action ) ) {
$response = apply_filters( 'cherry_handler_response_nonce', array(
'message' => $this->settings['sys_messages']['invalid_nonce'],
'type' => 'error-notice',
) );
wp_send_json( $response );
}
if ( ! empty( $this->settings['capability'] ) && ! current_user_can( $this->settings['capability'] ) ) {
$response = apply_filters( 'cherry_handler_response_capability', array(
'message' => $this->settings['sys_messages']['no_right'],
'type' => 'error-notice',
) );
wp_send_json( $response );
}
if ( ! empty( $this->settings['callback'] ) && is_callable( $this->settings['callback'] ) ) {
ob_start();
$data = call_user_func( $this->settings['callback'] );
if ( ! $data ) {
$data = ob_get_contents();
}
ob_end_clean();
$response = apply_filters( 'cherry_handler_response_data', array(
'message' => $this->settings['sys_messages']['access_is_allowed'],
'type' => 'success-notice',
'data' => $data,
) );
wp_send_json( $response );
}
} else {
$response = apply_filters( 'cherry_handler_invalid_data', array(
'message' => $this->settings['sys_messages']['invalid_base_data'],
'type' => 'error-notice',
) );
wp_send_json( $response );
}
}
/**
* Register and enqueue handlers js.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
wp_enqueue_script(
'cherry-handler-js',
esc_url( Cherry_Core::base_url( 'assets/js/min/cherry-handler.min.js', $this->module_path ) ),
array( 'jquery' ),
$this->core_version,
true
);
wp_enqueue_style(
'cherry-handler-css',
esc_url( Cherry_Core::base_url( 'assets/css/cherry-handler-styles.min.css', $this->module_path ) ),
array(),
$this->core_version,
'all'
);
}
/**
* Prepare data for henler script.
*
* @since 1.0.0
* @return void
*/
public function localize_script() {
$nonce = $this->create_nonce( $this->settings['action'] );
wp_localize_script( 'cherry-handler-js', $this->settings['id'],
array(
'action' => $this->settings['action'],
'nonce' => $nonce,
'type' => strtoupper( $this->settings['type'] ),
'data_type' => $this->settings['data_type'],
'is_public' => $this->settings['is_public'] ? 'true' : 'false',
'sys_messages' => $this->settings['sys_messages'],
)
);
if ( $this->settings['is_public'] ) {
wp_localize_script( 'cherry-handler-js', 'cherryHandlerAjaxUrl', array(
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
) );
}
}
/**
* Create nonce by action
*
* @param string $action Nonce name.
* @return string
*/
public function create_nonce( $action = '' ) {
if ( ! empty( $action ) ) {
return wp_create_nonce( $action );
}
return wp_create_nonce( 'cherry_ajax_nonce' );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,495 @@
<?php
/**
* Module Name: Interface Builder
* Description: The module for the creation of interfaces in the WordPress admin panel
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Interface_Builder' ) ) {
/**
* Class Cherry Interface Builder.
*
* @since 1.0.0
*/
class Cherry_Interface_Builder {
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $module_path;
/**
* Module settings.
*
* @since 1.0.0
* @access private
* @var array
*/
private $args = array(
'views' => array(
'section' => 'inc/views/section.php',
'component-tab-vertical' => 'inc/views/component-tab-vertical.php',
'component-tab-horizontal' => 'inc/views/component-tab-horizontal.php',
'component-toggle' => 'inc/views/component-toggle.php',
'component-accordion' => 'inc/views/component-accordion.php',
'component-repeater' => 'inc/views/component-repeater.php',
'settings' => 'inc/views/settings.php',
'control' => 'inc/views/control.php',
'settings-children-title' => 'inc/views/settings-children-title.php',
'tab-children-title' => 'inc/views/tab-children-title.php',
'toggle-children-title' => 'inc/views/toggle-children-title.php',
'form' => 'inc/views/form.php',
'html' => 'inc/views/html.php',
),
'views_args' => array(
'parent' => '',
'type' => '',
'view' => '',
'view_wrapping' => true,
'html' => '',
'scroll' => false,
'master' => false,
'title' => '',
'description' => '',
),
);
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* UI element instance.
*
* @since 1.0.0
* @access public
* @var object
*/
public $ui_elements = null;
/**
* The structure of the interface elements.
*
* @since 1.0.0
* @access private
* @var array
*/
private $structure = array();
/**
* Cherry_Interface_Builder constructor.
*
* @since 1.0.0
* @access public
* @return void
*/
public function __construct( $core, array $args = array() ) {
$this->args = array_merge_recursive(
$args,
$this->args
);
$this->core_version = $core->get_core_version();
$this->module_path = $args['module_path'];
$this->ui_elements = $core->init_module( 'cherry-ui-elements' );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
}
/**
* Register element type section.
*
* @since 1.0.0
* @access public
* @param array $args Options section.
* @return void
*/
public function register_section( array $args = array() ) {
$this->add_new_element( $args, 'section' );
}
/**
* Register element type component.
*
* @since 1.0.0
* @access public
* @param array $args Options component.
* @return void
*/
public function register_component( array $args = array() ) {
$this->add_new_element( $args, 'component' );
}
/**
* Register element type settings.
*
* @since 1.0.0
* @access public
* @param array $args Options settings.
* @return void
*/
public function register_settings( array $args = array() ) {
$this->add_new_element( $args, 'settings' );
}
/**
* Register element type control.
*
* @since 1.0.0
* @access public
* @param array $args Options control.
* @return void
*/
public function register_control( array $args = array() ) {
$this->add_new_element( $args, 'control' );
}
/**
* Register element type form.
*
* @since 1.0.0
* @access public
* @param array $args Options form.
* @return void
*/
public function register_form( array $args = array() ) {
$this->add_new_element( $args, 'form' );
}
/**
* Register element type html.
*
* @since 1.0.0
* @access public
* @param array $args Options control.
* @return void
*/
public function register_html( array $args = array() ) {
$this->add_new_element( $args, 'html' );
}
/**
* This function adds a new element to the structure.
*
* @since 1.0.0
* @access protected
* @param array $args Options new element.
* @param string $type Type new element.
* @return void
*/
protected function add_new_element( array $args = array(), $type = 'section' ) {
if ( ! isset( $args[0] ) && ! is_array( current( $args ) ) ) {
if ( 'control' !== $type && 'component' !== $type ) {
$args['type'] = $type;
}
$this->structure[ $args['id'] ] = $args;
} else {
foreach ( $args as $key => $value ) {
if ( 'control' !== $type && 'component' !== $type ) {
$value['type'] = $type;
}
$this->structure[ $key ] = $value;
}
}
}
/**
* Sorts the elements of the structure, adding child items to the parent.
*
* @since 1.0.0
* @access protected
* @param array $structure The original structure of the elements.
* @param string $parent_key The key of the parent element.
* @return array
*/
protected function sort_structure( array $structure = array(), $parent_key = null ) {
$new_array = array();
foreach ( $structure as $key => $value ) {
if (
( null === $parent_key && ! isset( $value['parent'] ) )
|| null === $parent_key && ! isset( $structure[ $value['parent'] ] )
|| ( isset( $value['parent'] ) && $value['parent'] === $parent_key )
) {
if ( ! isset( $value['id'] ) ) {
$value['id'] = $key;
}
if ( ! isset( $value['name'] ) ) {
$value['name'] = $key;
}
$new_array[ $key ] = $value;
$children = $this->sort_structure( $structure, $key );
if ( ! empty( $children ) ) {
$new_array[ $key ]['children'] = $children;
}
}
}
return $new_array;
}
/**
* Reset structure array.
* Call this method only after render.
*
* @since 1.0.1
* @return void
*/
public function reset_structure() {
$this->structure = array();
}
/**
* Get view for interface elements.
*
* @since 1.0.0
* @access protected
* @param string $type View type.
* @param array $args Input data.
* @return string
*/
protected function get_view( $type = 'control', array $args = array() ) {
if ( empty( $args['view'] ) ) {
$path = ( array_key_exists( $type, $this->args['views'] ) ) ? $this->args['views'][ $type ] : $this->args['views']['control'];
$path = is_array( $path ) ? $path[0] : $path;
$path = file_exists( $path ) ? $path : $this->module_path . $path;
} else {
$path = $args['view'];
}
return Cherry_Toolkit::render_view( $path, $args );
}
/**
* Render HTML elements.
*
* @since 1.0.0
* @access public
* @param bool $echo Input data.
* @param array $args The original structure of the elements.
* @return string
*/
public function render( $echo = true, array $args = array() ) {
if ( empty( $args ) ) {
$args = $this->structure;
}
if ( empty( $args ) ) {
return false;
}
$sorted_structure = $this->sort_structure( $args );
$output = $this->build( $sorted_structure );
$output = str_replace( array( "\r\n", "\r", "\n", "\t" ), '', $output );
$this->reset_structure();
return $this->output_method( $output, $echo );
}
/**
* Render HTML elements.
*
* @since 1.0.0
* @access protected
* @param array $args Input data.
* @return string
*/
protected function build( array $args = array() ) {
$output = '';
$views = $this->args['views'];
foreach ( $args as $key => $value ) {
$value = wp_parse_args(
$value,
$this->args['views_args']
);
$value['class'] = isset( $value['class'] ) ? $value['class'] . ' ' : '';
$value['class'] .= $value['id'] . ' ';
if ( $value['scroll'] ) {
$value['class'] .= 'cherry-scroll ';
}
if ( $value['master'] ) {
$value['class'] .= $value['master'] . ' ';
}
$type = array_key_exists( $value['type'], $views ) ? $value['type'] : 'field';
$has_child = isset( $value['children'] ) && is_array( $value['children'] ) && ! empty( $value['children'] );
switch ( $type ) {
case 'component-tab-vertical':
case 'component-tab-horizontal':
if ( $has_child ) {
$value['tabs'] = '';
foreach ( $value['children'] as $key_children => $value_children ) {
$value['tabs'] .= $this->get_view( 'tab-children-title', $value_children );
unset( $value['children'][ $key_children ]['title'] );
}
}
break;
case 'component-toggle':
case 'component-accordion':
if ( $has_child ) {
foreach ( $value['children'] as $key_children => $value_children ) {
$value['children'][ $key_children ]['title_in_view'] = $this->get_view( 'toggle-children-title', $value_children );
}
}
break;
case 'settings':
if ( isset( $value['title'] ) && $value['title'] ) {
$value['title'] = isset( $value['title_in_view'] ) ? $value['title_in_view'] : $this->get_view( 'settings-children-title', $value );
}
break;
case 'html':
$value['children'] = $value['html'];
break;
case 'form':
$value['accept-charset'] = isset( $value['accept-charset'] ) ? $value['accept-charset'] : 'utf-8';
$value['action'] = isset( $value['action'] ) ? $value['action'] : '' ;
$value['autocomplete'] = isset( $value['autocomplete'] ) ? $value['autocomplete'] : 'on';
$value['enctype'] = isset( $value['enctype'] ) ? $value['enctype'] : 'application/x-www-form-urlencoded';
$value['method'] = isset( $value['method'] ) ? $value['method'] : 'post';
$value['novalidate'] = ( isset( $value['novalidate'] ) && $value['novalidate'] ) ? 'novalidate' : '';
$value['target'] = isset( $value['target'] ) ? $value['target'] : '';
break;
case 'field':
$ui_args = $value;
$ui_args['class'] = isset( $ui_args['child_class'] ) ? $ui_args['child_class'] : '' ;
if ( isset( $ui_args['options_callback'] ) ) {
$ui_args['options'] = call_user_func( $ui_args['options_callback'] );
}
unset( $ui_args['master'] );
$value['children'] = $this->ui_elements->get_ui_element_instance( $ui_args['type'], $ui_args )->render();
break;
}
if ( $has_child ) {
$value['children'] = $this->build( $value['children'] );
}
$output .= ( $value['view_wrapping'] ) ? $this->get_view( $type, $value ) : $value['children'];
}
return $output;
}
/**
* Output HTML.
*
* @since 1.0.0
* @access protected
* @param string $output Output HTML.
* @param boolean $echo Output type.
* @return string
*/
protected function output_method( $output = '', $echo = true ) {
if ( ! filter_var( $echo, FILTER_VALIDATE_BOOLEAN ) ) {
return $output;
} else {
echo $output;
}
}
/**
* Enqueue javascript and stylesheet interface builder.
*
* @since 4.0.0
* @access public
* @return void
*/
public function enqueue_assets() {
wp_enqueue_script(
'cherry-interface-builder',
esc_url( Cherry_Core::base_url( 'inc/assets/min/cherry-interface-builder.min.js', $this->module_path ) ),
array( 'jquery' ),
$this->core_version,
true
);
wp_enqueue_style(
'cherry-interface-builder',
esc_url( Cherry_Core::base_url( 'inc/assets/min/cherry-interface-builder.min.css', $this->module_path ) ),
array(),
$this->core_version,
'all'
);
}
/**
* Returns the instance.
*
* @since 1.0.0
* @access public
* @return object
*/
public static function get_instance( $core, $args ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $core, $args );
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,17 @@
.cherry-ui-kit{
button{
*{
pointer-events: none;
}
}
}
.cherry-component{
&__content{
.cherry-settings__content{
display: none;
&.show{
display: inherit;
}
}
}
}

View File

@@ -0,0 +1,193 @@
/**
* Interface Builder
*/
;( function( $, CherryJsCore ) {
'use strict';
CherryJsCore.utilites.namespace( 'interfaceBuilder' );
CherryJsCore.interfaceBuilder = {
init: function() {
this.component.init();
$( document )
.on( 'cherryInterfaceBuilder', this.component.init.bind( this.component ) );
},
component: {
tabClass: '.cherry-tab',
accordionClass: '.cherry-accordion',
toggleClass: '.cherry-toggle',
buttonClass: '.cherry-component__button',
contentClass: '.cherry-settings__content',
buttonActiveClass: 'active',
showClass: 'show',
localStorage: {},
init: function () {
this.localStorage = this.getState() || {};
this.componentInit( this.tabClass );
this.componentInit( this.accordionClass );
this.componentInit( this.toggleClass );
this.addEvent();
},
addEvent: function() {
$( 'body' )
.off( 'click.cherryInterfaceBuilder' )
.on( 'click.cherryInterfaceBuilder',
this.tabClass + ' ' + this.buttonClass + ', ' +
this.toggleClass + ' ' + this.buttonClass + ', ' +
this.accordionClass + ' ' + this.buttonClass,
this.componentClick.bind( this )
);
},
componentInit: function( componentClass ) {
var _this = this,
components = $( componentClass ),
componentId = null,
button = null,
contentId = null,
notShow = '';
components.each( function( index, component ) {
component = $( component );
componentId = component.data( 'compotent-id' );
switch ( componentClass ) {
case _this.toggleClass:
if ( _this.localStorage[ componentId ] && _this.localStorage[ componentId ].length ) {
notShow = _this.localStorage[ componentId ].join( ', ' );
}
$( _this.contentClass, component )
.not( notShow )
.addClass( _this.showClass )
.prevAll( _this.buttonClass )
.addClass( _this.buttonActiveClass );
break;
case _this.tabClass:
case _this.accordionClass:
if ( _this.localStorage[ componentId ] ) {
contentId = _this.localStorage[ componentId ][ 0 ];
button = $( '[data-content-id="' + contentId + '"]', component );
} else {
button = $( _this.buttonClass, component ).eq( 0 );
contentId = button.data( 'content-id' );
}
_this.showElement( button, component, contentId );
break;
}
} );
},
componentClick: function( event ) {
var $target = $( event.target ),
$parent = $target.closest( this.tabClass + ', ' + this.accordionClass + ', ' + this.toggleClass ),
expr = new RegExp( this.tabClass + '|' + this.accordionClass + '|' + this.toggleClass ),
componentName = $parent[0].className.match( expr )[ 0 ].replace( ' ', '.' ),
contentId = $target.data( 'content-id' ),
componentId = $parent.data( 'compotent-id' ),
activeFlag = $target.hasClass( this.buttonActiveClass ),
itemClosed;
switch ( componentName ) {
case this.tabClass:
if ( ! activeFlag ) {
this.hideElement( $parent );
this.showElement( $target, $parent, contentId );
this.localStorage[ componentId ] = new Array( contentId );
this.setState();
}
break;
case this.accordionClass:
this.hideElement( $parent );
if ( ! activeFlag ) {
this.showElement( $target, $parent, contentId );
this.localStorage[ componentId ] = new Array( contentId );
} else {
this.localStorage[ componentId ] = {};
}
this.setState();
break;
case this.toggleClass:
$target
.toggleClass( this.buttonActiveClass )
.nextAll( contentId )
.toggleClass( this.showClass );
if ( Array.isArray( this.localStorage[ componentId ] ) ) {
itemClosed = this.localStorage[ componentId ].indexOf( contentId );
if ( -1 !== itemClosed ) {
this.localStorage[ componentId ].splice( itemClosed, 1 );
} else {
this.localStorage[ componentId ].push( contentId );
}
} else {
this.localStorage[ componentId ] = new Array( contentId );
}
this.setState();
break;
}
$target.blur();
return false;
},
showElement: function ( button, holder, contentId ) {
button
.addClass( this.buttonActiveClass );
holder
.data( 'content-id', contentId );
$( contentId, holder )
.addClass( this.showClass );
},
hideElement: function ( holder ) {
var contsntId = holder.data( 'content-id' );
$( '[data-content-id="' + contsntId + '"]', holder )
.removeClass( this.buttonActiveClass );
$( contsntId, holder )
.removeClass( this.showClass );
},
getState: function() {
try {
return JSON.parse( localStorage.getItem( 'interface-builder' ) );
} catch ( e ) {
return false;
}
},
setState: function() {
try {
localStorage.setItem( 'interface-builder', JSON.stringify( this.localStorage ) );
} catch ( e ) {
return false;
}
}
}
};
CherryJsCore.interfaceBuilder.init();
}( jQuery, window.CherryJsCore ) );

View File

@@ -0,0 +1,511 @@
$color-1: #fff; // Background color.
$widget-bg: #495159; // Background color in widgets.
$color-2: #efefef; // Background color.
$color-3: #96989a; // Description color and tabs button text color.
$color-4: #b4b7ba; //
$color-5: #f1f1f1; // Scrollbar background
$color-6: #e5e5e5; // Hover scrollbar background
$color-7: #206ff4; // Scrollbar track background
$link-color: #298ffc; // link color.
$link-hover-color: #23282d; // link hover color.
$shadow: 2px 2px 5px rgba(0,0,0,0.05); //Shadow.
$border: 1px solid rgba(0, 0, 0, 0.1) ;
$br-radius: 3px; // Border radius.
$padding: 5px;
$margin: 5px;
$max-heught: 700px;
@import "use-in-js";
html{
font-size: 13px;
}
.cherry-ui-kit{
h1{
font-weight: 700;
font-size: 2.308rem;
line-height: 2.308rem;
.dashicons{
font-size: 3rem;
line-height: inherit;
width: 20px;
margin: 0 $margin * 2 0 $margin * -0.5;
}
}
h2{
font-weight: 600;
font-size: 1.538rem;
line-height: 1.538rem;
.dashicons{
font-size: 2rem;
line-height: inherit;
width: 20px;
margin-right: $margin * 2;
}
}
h3{
font-weight: 600;
font-size: 1.231rem;
line-height: 1.231rem;
.dashicons{
font-size: 1.7rem;
line-height: inherit;
margin-right: $margin * 0.5;
}
}
h4{
font-weight: 500;
font-size: 1.077rem;
line-height: 1.077rem;
}
h5{
font-weight: 500;
font-size: 1.077rem;
line-height: 1.077rem;
}
h6{
font-weight: 400;
font-size: 1rem;
line-height: 1rem;
}
a{
color: $link-color;
text-decoration: none;
&:hover{
color: $link-hover-color;
}
&:focus{
outline: 1px solid rgba(41, 143, 252, .6);
box-shadow: 0px 0px 2px rgba(41,143,252,0.6);
}
}
&__description{
font-size: 0.9rem;
color: $color-3;
margin: $margin 0;
}
&__title{
margin: $margin*2 0;
}
&.hide{
display: none;
}
}
.cherry-control + .cherry-control, .cherry-settings + .cherry-control{
border-top: $border;
}
.cherry-section{
padding: $padding;
background-color: $color-1;
margin-left: -10px;
&__title, &__description{
margin: $margin 0 0 0;
}
& + .cherry-ui-kit {
border-top: $border;
}
@media ( min-width: 783px ) {
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
padding: $padding * 1.5;
margin: $margin * 1.5 $margin * 1.5 0 0;
&__holder{
background-color: $color-2;
border-radius: $br-radius;
padding: $padding * 1.5;
}
&__inner{
}
&__info{
background-color: $color-1;
border-radius: $br-radius;
padding: $padding * 1.5;
box-shadow: $shadow;
margin-bottom: $padding * 1.5;
}
.cherry-settings{
box-shadow: $shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
margin-top: $padding * 1.5;
&:first-child{
margin-top: 0;
}
}
}
@media ( min-width: 961px ) {
padding: $padding * 3;
margin: $margin * 2 $margin * 2 0 0;
&__info{
padding: $padding * 3;
margin-bottom: $padding * 3;
}
&__holder{
padding: $padding * 3;
}
.cherry-settings{
margin-top: $padding * 3;
}
}
}
.cherry-component{
padding: $padding * 2 0;
@media ( min-width: 783px ) {
padding: $padding * 1.5;
}
@media ( min-width: 961px ) {
padding: $padding * 3;
}
& + * {
border-top: $border;
}
&__title{
margin-top: 0;
}
& &__content{
.cherry-settings{
padding: 0;
border-top: none;
}
}
&__button{
display: block;
min-height: 45px;
.cherry-ui-kit__title {
color: inherit;
}
&.active, &:hover{
color: $link-color;
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
&:focus{
outline: none;
box-shadow: inset 0 0 1px 0 rgba(41,143,252,0.5);
transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
transition: all 300ms cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
&.cherry-accordion, &.cherry-toggle{
.cherry-component__button{
width: 100%;
padding: $padding * 1.5 $padding * 2;
border:0;
background: none;
cursor: pointer;
position: relative;
.widget &{
background-color: $widget-bg;
color: $color-1;
}
.cherry-toggle__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
>span[class*="icon"]{
position: absolute;
top: 50%;
right: 5px;
margin-top: -10px;
font-size: 25px;
color: $color-4;
padding: 5px 5px;
width: 10px;
height: 9px;
text-align: left;
overflow: hidden;
.widget &{
color: $color-1;
}
&.hide-icon{
&:before{
position: relative;
top: -8px;
left: -9px;
}
transform:scaleX(1);
transition: all 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
&.show-icon{
&:before{
position: relative;
top: -7px;
left: -9px;
}
transform:scaleX(0);
transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
&.active{
>span[class*="icon"]{
&.show-icon{
transform:scaleX(1);
transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
&.hide-icon{
transform:scaleX(0);
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
}
}
.cherry-component__button + .cherry-settings__content{
border-top: $border;
}
> .cherry-ui-kit__content{
& > .cherry-settings + .cherry-settings{
margin-top: $margin;
}
> .cherry-settings{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
.widget &{
box-shadow:none;
border-radius: 0;
border-left: 0;
border-right: 0;
}
}
}
}
&.cherry-tab{
.cherry-tab__tabs{
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
border-bottom: $border;
.cherry-component__button{
order: 0;
flex: 0 1 100%;
align-self: auto;
padding: $padding * 1.5 $padding * 2;
border: 0;
background: none;
cursor: pointer;
&.active{
-ms-box-shadow: inset 0px -3px 0px 0px $link-color;
box-shadow: inset 0px -3px 0px 0px $link-color;
}
.cherry-tab__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
& + button{
border-top: $border;
}
}
}
.cherry-tab__body{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
.cherry-settings{
box-shadow: none;
border-radius: 0;
border: none;
background-color: inherit;
margin: 0;
}
}
@media ( min-width: 783px ) {
.cherry-tab__tabs{
border: solid 1px rgba(0,0,0,0.1);
.cherry-component__button{
& + button{
border-top: none;
}
}
}
.cherry-tab__body{
border: none;
.cherry-tab__content{
border: $border;
}
}
&--horizontal{
>.cherry-tab__body{
border-radius: none;
>.cherry-tab__tabs{
flex-wrap: nowrap;
flex-direction: row;
border-radius:$br-radius $br-radius 0 0;
border-bottom: none;
.cherry-component__button{
flex: 0 1 auto;
}
}
>.cherry-tab__content{
border-radius: 0 0 $br-radius $br-radius;
}
}
}
&--vertical{
>.cherry-tab__body{
display: flex;
border-radius: none;
>.cherry-tab__tabs{
flex-direction: row;
-webkit-box-flex: 0;
flex: 0 1 20%;
border-radius:$br-radius 0 0 $br-radius;
border-right: none;
.cherry-component__button{
text-align: right;
.cherry-tab__title {
width: 100%;
}
&.active{
box-shadow: inset -3px 0px 0px $link-color;
}
}
}
>.cherry-tab__content{
-webkit-box-flex: 0;
flex: 0 1 80%;
border-radius: 0 $br-radius $br-radius 0;
}
}
}
}
@media ( min-width: 1200px ) {
&--vertical{
.cherry-tab__tabs{
flex: 0 1 20%;
}
.cherry-tab__content{
flex: 0 1 80%;
}
}
}
}
.widget &{
padding: 0;
&__content{
margin: 0 $margin * -1.5 $margin * 2;
.cherry-control{
padding: $padding * 1.5 $padding * 2;
}
}
}
}
.cherry-settings{
& + & {
border-top: $border;
}
& &__title{
margin-bottom: $margin;
}
&__description, & &__title{
margin-left: $margin;
@media ( min-width: 783px ) {
margin-left: $margin * 1.5;
}
@media ( min-width: 961px ) {
margin-left: $margin * 3;
}
}
}
.cherry-control{
padding: $padding * 3 0;
margin: 0 $margin;
&__title{
margin: 0 0 $margin 0 ;
}
&__description{
margin-top: 0;
}
.cherry-ui-container {
margin: 0;
}
@media (min-width: 783px) {
padding: $padding * 4;
margin: 0 $margin * 1.5;
display: flex;
flex-flow: row nowrap;
&__info{
-webkit-box-flex: 0;
flex: 0 1 30%;
padding-right: $padding * 1.5;
}
&__content{
-webkit-box-flex: 0;
flex: 0 1 70%;
}
}
@media ( min-width: 961px ) {
padding: $padding * 6 0;
margin: 0 $margin * 3;
}
.widget & {
padding: $padding * 1.5 0;
flex-direction: column;
&__content{
-webkit-box-flex: 0;
flex: 0 1 100%;
}
&__info{
-webkit-box-flex: 0;
flex: 0 1 100%;
padding-right: 0;
}
}
}
.cherry-section.cherry-scroll > .cherry-section__holder > .cherry-section__inner,
.cherry-tab__content > .cherry-scroll,
.cherry-accordion__content > .cherry-scroll > .cherry-settings__content,
.cherry-toggle__content > .cherry-scroll > .cherry-settings__content,
{
@media ( min-width: 783px ) {
max-height: $max-heught;
overflow-y: auto;
position: relative;
&::-webkit-scrollbar {
width: 10px;
height: 10px;
&-button {
width: 0px;
height: 0px;
}
&-thumb {
background-color: $link-color;
border: none;
border-radius: $br-radius;
&:hover, &:active {
background: $color-7;
}
}
&-track {
background-color: $color-1;
border: none;
border-radius: $br-radius;
}
&-corner {
background: transparent;
}
}
}
}

View File

@@ -0,0 +1 @@
!function(t,s){"use strict";s.utilites.namespace("interfaceBuilder"),s.interfaceBuilder={init:function(){this.component.init(),t(document).on("cherryInterfaceBuilder",this.component.init.bind(this.component))},component:{tabClass:".cherry-tab",accordionClass:".cherry-accordion",toggleClass:".cherry-toggle",buttonClass:".cherry-component__button",contentClass:".cherry-settings__content",buttonActiveClass:"active",showClass:"show",localStorage:{},init:function(){this.localStorage=this.getState()||{},this.componentInit(this.tabClass),this.componentInit(this.accordionClass),this.componentInit(this.toggleClass),this.addEvent()},addEvent:function(){t("body").off("click.cherryInterfaceBuilder").on("click.cherryInterfaceBuilder",this.tabClass+" "+this.buttonClass+", "+this.toggleClass+" "+this.buttonClass+", "+this.accordionClass+" "+this.buttonClass,this.componentClick.bind(this))},componentInit:function(s){var e=this,a=t(s),o=null,i=null,n=null,l="";a.each(function(a,c){switch(c=t(c),o=c.data("compotent-id"),s){case e.toggleClass:e.localStorage[o]&&e.localStorage[o].length&&(l=e.localStorage[o].join(", ")),t(e.contentClass,c).not(l).addClass(e.showClass).prevAll(e.buttonClass).addClass(e.buttonActiveClass);break;case e.tabClass:case e.accordionClass:e.localStorage[o]?(n=e.localStorage[o][0],i=t('[data-content-id="'+n+'"]',c)):(i=t(e.buttonClass,c).eq(0),n=i.data("content-id")),e.showElement(i,c,n)}})},componentClick:function(s){var e,a=t(s.target),o=a.closest(this.tabClass+", "+this.accordionClass+", "+this.toggleClass),i=new RegExp(this.tabClass+"|"+this.accordionClass+"|"+this.toggleClass),n=o[0].className.match(i)[0].replace(" ","."),l=a.data("content-id"),c=o.data("compotent-id"),r=a.hasClass(this.buttonActiveClass);switch(n){case this.tabClass:r||(this.hideElement(o),this.showElement(a,o,l),this.localStorage[c]=new Array(l),this.setState());break;case this.accordionClass:this.hideElement(o),r?this.localStorage[c]={}:(this.showElement(a,o,l),this.localStorage[c]=new Array(l)),this.setState();break;case this.toggleClass:a.toggleClass(this.buttonActiveClass).nextAll(l).toggleClass(this.showClass),Array.isArray(this.localStorage[c])?(e=this.localStorage[c].indexOf(l),-1!==e?this.localStorage[c].splice(e,1):this.localStorage[c].push(l)):this.localStorage[c]=new Array(l),this.setState()}return a.blur(),!1},showElement:function(s,e,a){s.addClass(this.buttonActiveClass),e.data("content-id",a),t(a,e).addClass(this.showClass)},hideElement:function(s){var e=s.data("content-id");t('[data-content-id="'+e+'"]',s).removeClass(this.buttonActiveClass),t(e,s).removeClass(this.showClass)},getState:function(){try{return JSON.parse(localStorage.getItem("interface-builder"))}catch(t){return!1}},setState:function(){try{localStorage.setItem("interface-builder",JSON.stringify(this.localStorage))}catch(t){return!1}}}},s.interfaceBuilder.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,30 @@
<?php
/**
* Accordion template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-accordion <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ) ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-component__content cherry-accordion__content" role="group" >
<?php echo $__data['children'] ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,30 @@
<?php
/**
* Repeater template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-repeater <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-component__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,35 @@
<?php
/**
* Horizontal tab template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-tab cherry-tab--horizontal <?php echo esc_attr( $__data['class'] ) ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-tab__body" >
<div class="cherry-tab__tabs" role="navigation" >
<?php echo $__data['tabs']; ?>
</div>
<div class="cherry-ui-kit__content cherry-component__content cherry-tab__content" role="group" >
<?php echo $__data['children']; ?>
</div>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,35 @@
<?php
/**
* Verticall tab template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-tab cherry-tab--vertical <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-tab__body" >
<div class="cherry-tab__tabs" role="navigation" >
<?php echo $__data['tabs']; ?>
</div>
<div class="cherry-ui-kit__content cherry-component__content cherry-tab__content" role="group" >
<?php echo $__data['children']; ?>
</div>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,30 @@
<?php
/**
* Toggle template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-toggle <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-component__content cherry-toggle__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,34 @@
<?php
/**
* Control template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-control <?php echo esc_attr( $__data['class'] ); ?>">
<?php if ( ! empty( $__data['title'] ) || ! empty( $__data['description'] ) ) { ?>
<div class="cherry-control__info">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h4 class="cherry-ui-kit__title cherry-control__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h4>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-control__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
</div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-control__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,24 @@
<?php
/**
* Form template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<form class="cherry-form <?php echo esc_attr( $__data['class'] ); ?>" id="<?php echo esc_attr( $__data['id'] ); ?>" name="<?php echo esc_attr( $__data['id'] ); ?>" accept-charset="<?php echo esc_attr( $__data['accept-charset'] ); ?>" action="<?php echo esc_attr( $__data['action'] ); ?>" autocomplete="<?php echo esc_attr( $__data['autocomplete'] ); ?>" enctype="<?php echo esc_attr( $__data['enctype'] ); ?>" method="<?php echo esc_attr( $__data['method'] ); ?>" target="<?php echo esc_attr( $__data['target'] ); ?>" <?php echo esc_attr( $__data['novalidate'] ); ?> >
<?php
if ( ! empty( $__data['children'] ) ) {
echo $__data['children'];
}
?>
</form>

View File

@@ -0,0 +1,24 @@
<?php
/**
* HTML template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit <?php echo esc_attr( $__data['class'] ); ?>">
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,36 @@
<?php
/**
* Section template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-section <?php echo esc_attr( $__data['class'] ); ?>" onclick="void(0)">
<div class="cherry-section__holder">
<div class="cherry-section__inner">
<div class="cherry-section__info">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h1 class="cherry-ui-kit__title cherry-section__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h1>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-section__description " role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
</div>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-section__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>
</div>
</div>

View File

@@ -0,0 +1,18 @@
<?php
/**
* Settings title template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<h3 class="cherry-ui-kit__title cherry-settings__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h3>

View File

@@ -0,0 +1,32 @@
<?php
/**
* Settings template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-settings <?php echo esc_attr( $__data['class'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) {
echo $__data['title'];
} ?>
<?php if ( ! empty( $__data['children'] ) || ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-settings__content" role="group" id="<?php echo esc_attr( $__data['id'] ); ?>" >
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-settings__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<?php echo $__data['children']; ?>
<?php } ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,20 @@
<?php
/**
* Tabs title template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<button class="cherry-tab__button cherry-component__button" role="button" title="<?php echo esc_attr( $__data['title'] ); ?>" aria-expanded="false" data-content-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<h3 class="cherry-ui-kit__title cherry-tab__title" aria-grabbed="true" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h3>
</button>

View File

@@ -0,0 +1,22 @@
<?php
/**
* Toggle title template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<button class="cherry-toggle__header cherry-component__button" role="button" aria-expanded="false" data-content-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<h3 class="cherry-ui-kit__title cherry-toggle__title" aria-grabbed="true" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h3>
<span class="dashicons dashicons-arrow-down hide-icon"></span>
<span class="dashicons dashicons-arrow-up show-icon"></span>
</button>

View File

@@ -0,0 +1,77 @@
var CherryJsCore = {};
( function( $ ) {
'use strict';
CherryJsCore = {
name: 'Cherry Js Core',
version: '1.0.0',
author: 'Cherry Team',
variable: {
$document: $( document ),
$window: $( window ),
browser_supported: true,
security: window.cherry_ajax,
loaded_assets: {
script: window.wp_load_script,
style: window.wp_load_style
},
ui_auto_init: ( 'true' === window.ui_init_object.auto_init ) ? true : false,
ui_auto_target: window.ui_init_object.targets
},
status: {
on_load: false,
is_ready: false
},
init: function(){
$( document ).on( 'ready', CherryJsCore.ready );
$( window ).on( 'load', CherryJsCore.load );
},
ready: function() {
CherryJsCore.status.is_ready = true;
// UI init after widget adding to sidebar
CherryJsCore.expressions.widget_ui_init();
},
load: function() {
CherryJsCore.status.on_load = true;
},
expressions: {
widget_ui_init: function() {
$( document ).on( 'widget-added widget-updated', function( event, data ) {
$( 'body' ).trigger( {
type: 'cherry-ui-elements-init',
_target: data
} );
} );
},
},
utilites: {
namespace: function( space_path ) {
var parts = space_path.split( '.' ),
parent = CherryJsCore,
length = parts.length,
i = 0;
for(i = 0; i < length; i += 1 ){
if( typeof parent[ parts[ i ] ] === 'undefined' ){
parent[ parts[ i ] ] = {};
}
parent = parent[ parts[ i ] ];
}
return parent;
}
}
};
CherryJsCore.init();
}(jQuery));

View File

@@ -0,0 +1 @@
var CherryJsCore={};!function(e){"use strict";(CherryJsCore={name:"Cherry Js Core",version:"1.0.0",author:"Cherry Team",variable:{$document:e(document),$window:e(window),browser_supported:!0,security:window.cherry_ajax,loaded_assets:{script:window.wp_load_script,style:window.wp_load_style},ui_auto_init:"true"===window.ui_init_object.auto_init,ui_auto_target:window.ui_init_object.targets},status:{on_load:!1,is_ready:!1},init:function(){e(document).on("ready",CherryJsCore.ready),e(window).on("load",CherryJsCore.load)},ready:function(){CherryJsCore.status.is_ready=!0,CherryJsCore.expressions.widget_ui_init()},load:function(){CherryJsCore.status.on_load=!0},expressions:{widget_ui_init:function(){e(document).on("widget-added widget-updated",function(r,t){e("body").trigger({type:"cherry-ui-elements-init",_target:t})})}},utilites:{namespace:function(e){var r=e.split("."),t=CherryJsCore,i=r.length,o=0;for(o=0;o<i;o+=1)void 0===t[r[o]]&&(t[r[o]]={}),t=t[r[o]];return t}}}).init()}(jQuery);

View File

@@ -0,0 +1,200 @@
<?php
/**
* Module Name: JS Core
* Description: Initializes global JS object which provides additional plugin functionality
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Js_Core' ) ) {
/**
* JS-core class.
*
* @since 1.0.0
* @since 1.0.1 Removed `module_directory` and `module_directory_uri` properties.
*/
class Cherry_Js_Core {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $module_path;
/**
* Default options.
*
* @since 1.0.0
* @var array
*/
private $options = array(
'product_type' => 'framework',
'src' => false,
'version' => false,
);
/**
* Class constructor.
*
* @since 1.0.0
* @param object $core Core instance.
* @param array $args Class args.
*/
public function __construct( $core, $args = array() ) {
$this->options = array_merge( $this->options, $args );
$this->core_version = $core->get_core_version();
$this->module_path = $args['module_path'];
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
add_action( 'wp_print_scripts', array( $this, 'localize_script' ) );
}
/**
* Register and enqueue JS-core.
*
* @since 1.0.0
*/
public function enqueue_cherry_scripts() {
if ( 'framework' === $this->options['product_type'] ) {
$src = esc_url( Cherry_Core::base_url( 'assets/js/min/cherry-js-core.min.js', $this->module_path ) );
$version = $this->core_version;
} else {
$src = ( ! empty( $this->options['src'] ) ? esc_url( $this->options['src'] ) : false );
$version = ( ! empty( $this->options['version'] ) ? absint( $this->options['src'] ) : false );
}
wp_enqueue_script(
'cherry-js-core',
$src,
array( 'jquery' ),
$this->core_version,
true
);
}
/**
* Retrieve a scripts list.
*
* @since 1.0.0
* @return $array
*/
private function get_include_script() {
return $this->add_suffix( '.js', wp_scripts()->queue );
}
/**
* Retrieve a styles list.
*
* @since 1.0.0
* @return $array
*/
private function get_include_style() {
return $this->add_suffix( '.css', wp_styles()->queue );
}
/**
* [get_ui_init_settings]
*
* @since 1.0.0
* @return $array
*/
private function get_ui_init_settings() {
// Default auto ui init settings.
$ui_init_settings = array(
'auto_init' => false,
'targets' => array(),
);
/**
* Filter to determine the list of selectors and the value of the automatic initialization ui js scripts
*
* @var array
*/
return apply_filters( 'cherry_core_js_ui_init_settings', $ui_init_settings );
}
/**
* Add suffix to array.
*
* @since 1.0.0
*/
private function add_suffix( $suffix, $array ) {
foreach ( $array as $key => $value ) {
$array[ $key ] = $value . $suffix;
}
return $array;
}
/**
* Prepare data for API script.
*
* @since 1.0.0
* @return void
*/
public function localize_script() {
wp_localize_script( 'cherry-js-core', 'wp_load_style', $this->get_include_style() );
wp_localize_script( 'cherry-js-core', 'wp_load_script', $this->get_include_script() );
wp_localize_script( 'cherry-js-core', 'cherry_ajax', wp_create_nonce( 'cherry_ajax_nonce' ) );
$ui_init_settings = $this->get_ui_init_settings();
$ui_init_settings['auto_init'] = ( true == $ui_init_settings['auto_init'] ) ? 'true' : 'false';
wp_localize_script( 'cherry-js-core', 'ui_init_object', $ui_init_settings );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $core, $args );
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,68 @@
/**
* Post formats related scripts
* @use CherryJsCore
*/
( function($, CherryJsCore){
'use strict';
CherryJsCore.utilites.namespace( 'post_formats' );
CherryJsCore.post_formats = {
init: function () {
var self = this;
if ( CherryJsCore.status.document_ready ) {
self.render( self );
} else {
CherryJsCore.variable.$document.on( 'ready', self.render( self ) );
}
},
render: function ( self ) {
// Init slider scripts
self.initalize( 'slider' );
// Init popup scripts
self.initalize( 'popup' );
},
initalize: function( object ) {
$(window).load(function () {
$( '*[data-cherry' + object + '="1"]' ).each( function() {
var plugin = $( this ).data( object ),
init = $( this ).data( 'init' );
$( this ).data( 'initalized', false );
$( this ).trigger({
type: 'cherry-post-formats-custom-init',
item: $( this ),
object: object
});
if ( true === $( this ).data( 'initalized' ) ) {
return 1;
}
if ( ! plugin ) {
return !1;
}
if ( ! $.isFunction( jQuery.fn[ plugin ] ) ) {
return !1;
}
$( this )[ plugin ]( init );
});
});
}
};
CherryJsCore.post_formats.init();
} (jQuery, window.CherryJsCore) );

View File

@@ -0,0 +1 @@
!function(t,i){"use strict";i.utilites.namespace("post_formats"),i.post_formats={init:function(){var t=this;i.status.document_ready?t.render(t):i.variable.$document.on("ready",t.render(t))},render:function(t){t.initalize("slider"),t.initalize("popup")},initalize:function(i){t(window).load(function(){t("*[data-cherry"+i+'="1"]').each(function(){var n=t(this).data(i),e=t(this).data("init");return t(this).data("initalized",!1),t(this).trigger({type:"cherry-post-formats-custom-init",item:t(this),object:i}),!0===t(this).data("initalized")?1:n?t.isFunction(jQuery.fn[n])?(t(this)[n](e),void 0):!1:!1})})}},i.post_formats.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,81 @@
<?php
/**
* Facebook embed
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Facebook_Embed' ) ) {
/**
* Define Cherry_Facebook_Embed class
*/
class Cherry_Facebook_Embed {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
function __construct() {
add_filter( 'init', array( $this, 'add_facebook' ) );
}
/**
* Register Facebook provider
*
* @since 1.0.0
* @param array $providers Existing providers.
*/
public function add_facebook( $providers ) {
$endpoints = array(
'#https?://www\.facebook\.com/video.php.*#i' => 'https://www.facebook.com/plugins/video/oembed.json/',
'#https?://www\.facebook\.com/.*/videos/.*#i' => 'https://www.facebook.com/plugins/video/oembed.json/',
'#https?://www\.facebook\.com/.*/posts/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/.*/activity/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/photo(s/|.php).*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/permalink.php.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/media/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/questions/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/notes/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
);
foreach ( $endpoints as $pattern => $endpoint ) {
wp_oembed_add_provider( $pattern, $endpoint, true );
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,545 @@
<?php
/**
* Module Name: Post Meta
* Description: Manage post meta
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Post_Meta' ) ) {
/**
* Post meta management module.
*
* @since 1.0.0
* @since 1.0.2 Removed `module_directory` property.
*/
class Cherry_Post_Meta {
/**
* Module slug.
*
* @var string
*/
public $module_slug = 'cherry-post-meta';
/**
* Module arguments.
*
* @var array
*/
public $args = array();
/**
* Interface builder instance.
*
* @var object
*/
public $builder = null;
/**
* Core instance.
*
* @var object
*/
public $core = null;
/**
* Current nonce name to check.
*
* @var null
*/
public $nonce = 'cherry-meta-nonce';
/**
* Storage of meta values.
*
* @since 1.0.0
* @var array
*/
public $meta_values = array();
/**
* Constructor for the module.
*
* @since 1.0.0
*/
public function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args(
$args,
array(
'id' => 'cherry-post-metabox',
'title' => '',
'page' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'single' => false,
'callback_args' => false,
'fields' => array(),
)
);
if ( empty( $this->args['fields'] ) ) {
return;
}
$this->builder = $this->core->init_module( 'cherry-interface-builder', array() );
$this->init_columns_actions();
if ( ! $this->builder ) {
return;
}
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 );
add_action( 'save_post', array( $this, 'save_meta' ), 10, 2 );
}
/**
* Initalize admin columns
*
* @return void
*/
public function init_columns_actions() {
if ( empty( $this->args['admin_columns'] ) ) {
return;
}
if ( ! is_array( $this->args['page'] ) ) {
$pages = array( $this->args['page'] );
} else {
$pages = $this->args['page'];
}
foreach ( $pages as $page ) {
add_filter( 'manage_edit-' . $page . '_columns', array( $this, 'edit_columns' ) );
add_action( 'manage_' . $page . '_posts_custom_column', array( $this, 'manage_columns' ), 10, 2 );
}
}
/**
* Edit admin columns
*
* @since 1.1.3
* @param array $columns current post table columns.
* @return array
*/
public function edit_columns( $columns ) {
foreach ( $this->args['admin_columns'] as $column_key => $column_data ) {
if ( empty( $column_data['label'] ) ) {
continue;
}
if ( ! empty( $column_data['position'] ) && 0 !== (int) $column_data['position'] ) {
$length = count( $columns );
if ( (int) $column_data['position'] > $length ) {
$columns[ $column_key ] = $column_data['label'];
}
$columns_before = array_slice( $columns, 0, (int) $column_data['position'] );
$columns_after = array_slice( $columns, (int) $column_data['position'], $length - (int) $column_data['position'] );
$columns = array_merge(
$columns_before,
array(
$column_key => $column_data['label'],
),
$columns_after
);
} else {
$columns[ $column_key ] = $column_data['label'];
}
}
return $columns;
}
/**
* Add output for custom columns.
*
* @since 1.1.3
* @param string $column current post list categories.
* @param int $post_id current post ID.
* @return void
*/
public function manage_columns( $column, $post_id ) {
if ( empty( $this->args['admin_columns'][ $column ] ) ) {
return;
}
if ( ! empty( $this->args['admin_columns'][ $column ]['callback'] ) && is_callable( $this->args['admin_columns'][ $column ]['callback'] ) ) {
call_user_func( $this->args['admin_columns'][ $column ]['callback'], $column, $post_id );
} else {
echo get_post_meta( $post_id, $column, true );
}
}
/**
* Check if defined metabox is allowed on current page
*
* @since 1.0.0
* @return boolean
*/
public function is_allowed_page() {
global $current_screen;
if ( empty( $current_screen ) ) {
return false;
}
if ( is_array( $this->args['page'] ) && ! in_array( $current_screen->id, $this->args['page'] ) ) {
return false;
}
if ( is_string( $this->args['page'] ) && $current_screen->id !== $this->args['page'] ) {
return false;
}
return true;
}
/**
* Add meta box handler
*
* @since 1.0.0
* @param [type] $post_type The post type of the current post being edited.
* @param object $post The current post object.
* @return void
*/
public function add_meta_boxes( $post_type, $post ) {
if ( ! $this->is_allowed_page() ) {
return;
}
add_meta_box(
$this->args['id'],
$this->args['title'],
array( $this, 'render_metabox' ),
$this->args['page'],
$this->args['context'],
$this->args['priority'],
$this->args['callback_args']
);
}
/**
* Render metabox funciton
*
* @since 1.0.0
* @param object $post The post object currently being edited.
* @param array $metabox Specific information about the meta box being loaded.
* @return void
*/
public function render_metabox( $post, $metabox ) {
/**
* Filter custom metabox output. Prevent from showing main box, if user output passed
*
* @var string
*/
$custom_box = apply_filters( 'cherry_post_meta_custom_box', false, $post, $metabox );
if ( false !== $custom_box ) {
echo $custom_box;
return;
}
wp_nonce_field( $this->nonce, $this->nonce );
/**
* Hook fires before metabox output started.
*/
do_action( 'cherry_post_meta_box_before' );
$this->get_fields( $post );
/**
* Hook fires after metabox output finished.
*/
do_action( 'cherry_post_meta_box_after' );
}
/**
* Get registered control fields
*
* @since 1.0.0
* @since 1.2.0 Use interface builder for HTML rendering.
* @param mixed $post Current post object.
* @return void
*/
public function get_fields( $post ) {
if ( is_array( $this->args['single'] ) && isset( $this->args['single']['key'] ) ) {
$this->meta_values = get_post_meta( $post->ID, $this->args['single']['key'], true );
}
$zero_allowed = apply_filters(
'cherry_zero_allowed_controls',
array(
'stepper',
'slider',
)
);
foreach ( $this->args['fields'] as $key => $field ) {
$default = Cherry_Toolkit::get_arg( $field, 'value', '' );
$value = $this->get_meta( $post, $key, $default );
if ( isset( $field['options_callback'] ) ) {
$field['options'] = call_user_func( $field['options_callback'] );
}
$element = Cherry_Toolkit::get_arg( $field, 'element', 'control' );
$field['id'] = Cherry_Toolkit::get_arg( $field, 'id', $key );
$field['name'] = Cherry_Toolkit::get_arg( $field, 'name', $key );
$field['type'] = Cherry_Toolkit::get_arg( $field, 'type', '' );
$field['value'] = $value;
// Fix zero values for stepper and slider
if ( ! $value && in_array( $field['type'], $zero_allowed ) ) {
$field['value'] = 0;
}
$register_callback = 'register_' . $element;
if ( method_exists( $this->builder, $register_callback ) ) {
call_user_func( array( $this->builder, $register_callback ), $field );
}
}
$this->builder->render();
}
/**
* Save additional taxonomy meta on edit or create tax
*
* @since 1.0.0
* @param int $post_id The ID of the current post being saved.
* @param object $post The post object currently being saved.
* @return void|int
*/
public function save_meta( $post_id, $post = '' ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! isset( $_POST[ $this->nonce ] ) || ! wp_verify_nonce( $_POST[ $this->nonce ], $this->nonce ) ) {
return;
}
$posts = ! empty( $this->args['page'] ) ? $this->args['page'] : array( 'post' );
$posts = is_array( $posts ) ? $posts : array( $posts );
$maybe_break = false;
foreach ( $posts as $post_type ) {
if ( get_post_type( $post_id ) !== $post_type ) {
$maybe_break = true;
continue;
}
$maybe_break = false;
$obj = get_post_type_object( $post_type );
if ( ! isset( $obj->cap->edit_posts ) || ! current_user_can( $obj->cap->edit_posts ) ) {
$maybe_break = true;
continue;
}
break;
}
if ( true === $maybe_break ) {
return;
}
if ( ! $this->is_allowed_page() ) {
return;
}
if ( ! is_object( $post ) ) {
$post = get_post();
}
/**
* Hook on current metabox saving
*/
do_action( 'cherry_save_meta_' . $this->args['id'] );
if ( is_array( $this->args['single'] ) && isset( $this->args['single']['key'] ) ) {
$this->save_meta_mod( $post_id );
} else {
$this->save_meta_option( $post_id );
}
}
/**
* Save all meta values as a one array value in `wp_postmeta` table.
*
* @since 1.1.0
* @param int $post_id Post ID.
*/
public function save_meta_mod( $post_id ) {
$meta_key = $this->args['single']['key'];
// Array of new post meta value.
$new_meta_value = array();
if ( empty( $_POST[ $meta_key ] ) ) {
return;
}
foreach ( $_POST[ $meta_key ] as $key => $value ) {
$new_meta_value[ $key ] = $this->sanitize_meta( $key, $value );
}
// Get current post meta data.
$meta_value = get_post_meta( $post_id, $meta_key, true );
if ( $new_meta_value && '' == $meta_value ) {
add_post_meta( $post_id, $meta_key, $new_meta_value, true );
} elseif ( $new_meta_value && $new_meta_value != $meta_value ) {
update_post_meta( $post_id, $meta_key, $new_meta_value );
} elseif ( empty( $new_meta_value ) && $meta_value ) {
delete_post_meta( $post_id, $meta_key, $meta_value );
}
}
/**
* Save each meta value as a single value in `wp_postmeta` table.
*
* @since 1.1.0
* @param int $post_id Post ID.
*/
public function save_meta_option( $post_id ) {
foreach ( $this->args['fields'] as $key => $field ) {
if ( isset( $field['element'] ) && 'control' !== $field['element'] ) {
continue;
}
if ( empty( $_POST[ $key ] ) ) {
update_post_meta( $post_id, $key, false );
continue;
}
$value = $this->sanitize_meta( $key, $_POST[ $key ] );
update_post_meta( $post_id, $key, $value );
}
}
/**
* Sanitize passed meta value
*
* @since 1.1.3
* @param string $key Meta key to sanitize.
* @param mixed $value Meta value.
* @return mixed
*/
public function sanitize_meta( $key, $value ) {
if ( empty( $this->args['fields'][ $key ]['sanitize_callback'] ) ) {
return $this->sanitize_deafult( $value );
}
if ( ! is_callable( $this->args['fields'][ $key ]['sanitize_callback'] ) ) {
return $this->sanitize_deafult( $value );
}
return call_user_func(
$this->args['fields'][ $key ]['sanitize_callback'],
$value,
$key,
$this->args['fields'][ $key ]
);
}
/**
* Cleare value with sanitize_text_field if not is array
*
* @since 1.1.3
* @param mixed $value Passed value.
* @return mixed
*/
public function sanitize_deafult( $value ) {
return is_array( $value ) ? $value : sanitize_text_field( $value );
}
/**
* Retrieve post meta field.
*
* @since 1.1.0
* @since 1.2.0 Process default value.
*
* @param object $post Current post object.
* @param string $key The meta key to retrieve.
* @param mixed $default Default value.
* @return string
*/
public function get_meta( $post, $key, $default = false ) {
if ( ! is_object( $post ) ) {
return '';
}
if ( is_array( $this->args['single'] ) && isset( $this->args['single']['key'] ) ) {
return isset( $this->meta_values[ $key ] ) ? $this->meta_values[ $key ] : $default;
}
$meta = get_post_meta( $post->ID, $key, false );
return ( empty( $meta ) ) ? $default : $meta[0];
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
if ( ! is_admin() ) {
return;
}
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,301 @@
<?php
/**
* Module Name: Term Meta
* Description: Manage term metadata
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Term_Meta' ) ) {
/**
* Term meta management module
*/
class Cherry_Term_Meta {
/**
* Module slug
*
* @var string
*/
public $module_slug = 'cherry-term-meta';
/**
* Module arguments
*
* @var array
*/
public $args = array();
/**
* Existing field types
*
* @var array
*/
public $field_types = array();
/**
* UI builder instance
*
* @var object
*/
public $ui_builder = null;
/**
* Already registered field.
*
* @since 1.0.2
* @var array
*/
static public $register_fields = array();
/**
* Core instance
*
* @var object
*/
public $core = null;
/**
* Constructor for the module
*/
function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args( $args, array(
'tax' => 'category',
'priority' => 10,
'fields' => array(),
) );
if ( empty( $this->args['fields'] ) ) {
return;
}
add_action( 'admin_enqueue_scripts', array( $this, 'init_ui' ), 1 );
$priority = intval( $this->args['priority'] );
$tax = esc_attr( $this->args['tax'] );
add_action( "{$tax}_add_form_fields", array( $this, 'render_add_fields' ), $priority );
add_action( "{$tax}_edit_form_fields", array( $this, 'render_edit_fields' ), $priority, 2 );
add_action( "created_{$tax}", array( $this, 'save_meta' ) );
add_action( "edited_{$tax}", array( $this, 'save_meta' ) );
}
/**
* Init UI builder.
*
* @since 1.0.0
* @return bool
*/
public function init_ui() {
global $current_screen;
if ( empty( $current_screen ) || ! in_array( $current_screen->base, array( 'edit-tags', 'term' ) ) ) {
return false;
}
array_walk( $this->args['fields'], array( $this, 'set_field_types' ) );
if ( in_array( 'slider', $this->field_types ) ) {
$this->field_types[] = 'stepper';
}
$this->ui_builder = $this->core->init_module( 'cherry-ui-elements', $this->field_types );
return true;
}
/**
* Render add term form fields
*
* @since 1.0.0
* @param [type] $taxonomy taxonomy name.
* @return void
*/
public function render_add_fields( $taxonomy ) {
$format = '<div style="padding:10px 0;">%s</div>';
echo $this->get_fields( false, $taxonomy, $format );
}
/**
* Render edit term form fields
*
* @since 1.0.0
* @param object $term current term object.
* @param [type] $taxonomy taxonomy name.
* @return void
*/
public function render_edit_fields( $term, $taxonomy ) {
$format = '<tr class="form-field cherry-term-meta-wrap"><th>&nbsp;</th><td>%s</td></tr>';
echo $this->get_fields( $term, $taxonomy, $format );
}
/**
* Get registered control fields
*
* @since 1.0.0
* @param mixed $term current term object.
* @param [type] $taxonomy current taxonomy name.
* @return string
*/
public function get_fields( $term, $taxonomy, $format = '%s' ) {
$result = '';
foreach ( $this->args['fields'] as $key => $field ) {
if ( in_array( $key, Cherry_Term_Meta::$register_fields ) ) {
continue;
} else {
Cherry_Term_Meta::$register_fields[] = $key;
}
if ( false !== $term ) {
$value = get_term_meta( $term->term_id, $key, true );
} else {
$value = '';
}
$value = ! empty( $value ) ? $value : Cherry_Toolkit::get_arg( $field, 'value', '' );
if ( isset( $field['options_callback'] ) ) {
$options = call_user_func( $field['options_callback'] );
} else {
$options = Cherry_Toolkit::get_arg( $field, 'options', array() );
}
$args = array(
'type' => Cherry_Toolkit::get_arg( $field, 'type', 'text' ),
'id' => $key,
'name' => $key,
'value' => $value,
'label' => Cherry_Toolkit::get_arg( $field, 'label', '' ),
'options' => $options,
'multiple' => Cherry_Toolkit::get_arg( $field, 'multiple', false ),
'filter' => Cherry_Toolkit::get_arg( $field, 'filter', false ),
'size' => Cherry_Toolkit::get_arg( $field, 'size', 1 ),
'null_option' => Cherry_Toolkit::get_arg( $field, 'null_option', 'None' ),
'multi_upload' => Cherry_Toolkit::get_arg( $field, 'multi_upload', true ),
'library_type' => Cherry_Toolkit::get_arg( $field, 'library_type', 'image' ),
'upload_button_text' => Cherry_Toolkit::get_arg( $field, 'upload_button_text', 'Choose' ),
'max_value' => Cherry_Toolkit::get_arg( $field, 'max_value', '100' ),
'min_value' => Cherry_Toolkit::get_arg( $field, 'min_value', '0' ),
'max' => Cherry_Toolkit::get_arg( $field, 'max', '100' ),
'min' => Cherry_Toolkit::get_arg( $field, 'min', '0' ),
'step_value' => Cherry_Toolkit::get_arg( $field, 'step_value', '1' ),
'style' => Cherry_Toolkit::get_arg( $field, 'style', 'normal' ),
'display_input' => Cherry_Toolkit::get_arg( $field, 'display_input', true ),
'controls' => Cherry_Toolkit::get_arg( $field, 'controls', array() ),
'fields' => Cherry_Toolkit::get_arg( $field, 'fields', array() ),
'auto_parse' => Cherry_Toolkit::get_arg( $field, 'auto_parse', false ),
'icon_data' => Cherry_Toolkit::get_arg( $field, 'icon_data', array() ),
'toggle' => Cherry_Toolkit::get_arg( $field, 'toggle', array(
'true_toggle' => 'On',
'false_toggle' => 'Off',
'true_slave' => '',
'false_slave' => '',
) ),
'class' => Cherry_Toolkit::get_arg( $field, 'class' ),
'required' => Cherry_Toolkit::get_arg( $field, 'required', false ),
'placeholder' => Cherry_Toolkit::get_arg( $field, 'placeholder' ),
'master' => Cherry_Toolkit::get_arg( $field, 'master' ),
'title_field' => Cherry_Toolkit::get_arg( $field, 'title_field' ),
'ui_kit' => Cherry_Toolkit::get_arg( $field, 'ui_kit', true ),
);
$current_element = $this->ui_builder->get_ui_element_instance( $args['type'], $args );
$result .= sprintf( $format, $current_element->render() );
}
return $result;
}
/**
* Store field types used in this widget into class property
*
* @since 1.0.0
* @param array $field field data.
* @param [type] $id field key.
* @return bool
*/
public function set_field_types( $field, $id ) {
if ( is_array( $field ) || ! isset( $field['type'] ) ) {
return false;
}
if ( ! in_array( $field['type'], $this->field_types ) ) {
$this->field_types[] = $field['type'];
}
return true;
}
/**
* Save additional taxonomy meta on edit or create tax
*
* @since 1.0.0
* @param int $term_id Term ID.
* @return bool
*/
public function save_meta( $term_id ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return false;
}
foreach ( $this->args['fields'] as $key => $field ) {
if ( ! isset( $_POST[ $key ] ) ) {
continue;
}
if ( is_array( $_POST[ $key ] ) ) {
$new_val = array_filter( $_POST[ $key ] );
} else {
$new_val = esc_attr( $_POST[ $key ] );
}
update_term_meta( $term_id, $key, $new_val );
}
return true;
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,217 @@
<?php
/**
* Module Name: Framework Toolkit
* Description: Framework Toolkit contains various PHP utilities
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Toolkit' ) ) {
/**
* Various PHP utilities
*/
class Cherry_Toolkit {
/**
* Module slug
*
* @var string Module slug
*/
public $module_slug = 'cherry-toolkit';
/**
* Constructor for the module
*
* @param Cherry_Core $core Core instance.
* @param array $args Module arguments.
*/
public function __construct( $core, $args ) {}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
/**
* Safely get attribute from field settings array.
*
* @since 1.0.0
* @param array $field arguments array.
* @param string|int|float $arg argument key.
* @param mixed $default default argument value.
* @return mixed
*/
public static function get_arg( $field, $arg, $default = '' ) {
if ( is_array( $field ) && isset( $field[ $arg ] ) ) {
return $field[ $arg ];
}
return $default;
}
/**
* Get class instance
*
* @param string $class_name Class name.
* @param Cherry_Core $core Core instance.
* @param array $args Additional arguments.
* @return object New class instance.
* @throws InvalidArgumentException If class does not exists.
*/
public static function get_class_instance( $class_name = '', $core, $args ) {
if ( ! class_exists( $class_name ) ) {
throw new InvalidArgumentException( 'Class "' . $class_name . '" doesn\'t exists' );
}
return new $class_name( $core, $args );
}
/**
* Render view
*
* @param string $path View path.
* @param array $data Include data.
* @return string Rendered html.
*/
public static function render_view( $path, array $data = array() ) {
// Add parameters to temporary query variable.
if ( array_key_exists( 'wp_query', $GLOBALS ) ) {
if ( is_array( $GLOBALS['wp_query']->query_vars ) ) {
$GLOBALS['wp_query']->query_vars['__data'] = $data;
}
}
ob_start();
load_template( $path, false );
$result = ltrim( ob_get_clean() );
/**
* Remove temporary wp query variable
* Yeah. I'm paranoic.
*/
if ( array_key_exists( 'wp_query', $GLOBALS ) ) {
if ( is_array( $GLOBALS['wp_query']->query_vars ) ) {
unset( $GLOBALS['wp_query']->query_vars['__data'] );
}
}
// Return the compiled view and terminate the output buffer.
return $result;
}
/**
* Remove empty elements
*
* @param array $arr --- array with empty elements.
* @return array --- array without empty elements
*/
public static function remove_empty( $arr ) {
return array_filter( $arr, array( __CLASS__, 'remove_empty_check' ) );
}
/**
* Check if empty.
* It's need for PHP 5.2.4 version
*
* @param [type] $var variable.
* @return boolean
*/
public static function remove_empty_check( $var ) {
return '' != $var;
}
/**
* Join array to string
*
* @param array $arr --- array like 'key' => 'value'.
* @return string --- joined string
*/
public static function join( $arr = array() ) {
$arr = self::remove_empty( $arr );
$result = array();
foreach ( $arr as $key => $value ) {
$result[] = sprintf( '%s="%s"', $key, $value );
}
return implode( ' ', $result );
}
/**
* Lave just right keys in array
*
* @param array $right_keys right keys to leave.
* @param array $array list.
* @return array
*/
public static function leave_right_keys( $right_keys, $array ) {
$right_keys = (array) $right_keys;
$array = (array) $array;
if ( count( $array ) ) {
foreach ( $array as $key => $value ) {
if ( ! in_array( $key, $right_keys ) ) {
unset( $array[ $key ] );
}
}
}
return $array;
}
/**
* Safely get file content by path
*
* @param string $filepath Path to file.
* @return mixed
*/
public static function get_file( $filepath ) {
if ( ! file_exists( $filepath ) ) {
return false;
}
ob_start();
include $filepath;
return ob_get_clean();
}
/**
* Remove some keys form array
*
* @param [type] $right_keys keys to remove.
* @param [type] $array where we want remove this keys.
* @return array without keys
*/
public static function remove_right_keys( $right_keys, $array ) {
$right_keys = (array) $right_keys;
$array = (array) $array;
if ( count( $right_keys ) ) {
foreach ( $right_keys as $key ) {
if ( array_key_exists( $key, $array ) ) {
unset( $array[ $key ] );
}
}
}
return $array;
}
}
}

View File

@@ -0,0 +1,110 @@
$lock-bg-color: rgba(0,0,0,0.9);
.cherry-lock-element{
user-select: none;
cursor: no-drop;
position: relative;
filter: grayscale( 100% );
&.inline-block{
display: inline-block;
}
& label{
position: relative;
}
.cherry-lable-content,
.cherry-checkbox-item,
.select2-container,
> *:first-child{
opacity: 0.5;
pointer-events: none;
}
a.cherry-lock-element__area{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2000;
cursor: no-drop;
&:focus{
outline: none;
box-shadow: none;
}
&:hover{
.cherry-lock-element__label{
animation-name: lock_show;
animation-duration: 450ms;
animation-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}
}
}
&__label {
opacity: 0;
display: inline-block;
background-color: $lock-bg-color;
border-radius: 5px;
color: #fff;
padding: 8px 10px;
position: absolute;
white-space: nowrap;
top: -10px;
left: 50%;
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
will-change: auto;
pointer-events: none;
font-size: 14px;
line-height: 16px;
animation-name: lock_hide;
animation-duration: 200ms;
animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
animation-fill-mode: both;
transform-origin: 0% 0%;
* + *{
margin-right: 5px;
}
&:after {
border: solid;
border-color: $lock-bg-color transparent;
border-width: 6px 6px 0 6px;
bottom: -5px;
margin-left: -6px;
content: "";
left: 50%;
position: absolute;
}
}
}
@keyframes lock_show {
0% {
opacity: 0;
filter: blur(5px);
transform: scale( 0 ) translate(-50%, 200% );
}
60% {
opacity: 0.8;
transform: scale( 1.1 ) translate(-50%, -130% );
}
100% {
opacity: 1;
filter: blur(0px);
transform: scale( 1 ) translate(-50%, -100% );
}
}
@keyframes lock_hide {
0% {
opacity: 1;
filter: blur(0px);
transform: scale( 1 ) translate(-50%, -100%);
}
100% {
opacity: 0;
filter: blur(3px);
transform: scale( 0 ) translate(-50%, 200%);
}
}

View File

@@ -0,0 +1,171 @@
<?php
/**
* Module Name: UI Elements
* Description: Class for the building ui elements
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_UI_Elements' ) ) {
/**
* Class for the building ui elements.
*
* @since 1.0.0
* @since 1.0.3 Removed `module_directory` and `module_directory_uri` properties.
*/
class Cherry_UI_Elements {
/**
* Default arguments.
*
* @since 1.0.0
* @var array
*/
private $args = array(
'ui_elements' => array(
'text',
'textarea',
'select',
'checkbox',
'radio',
'colorpicker',
'media',
'stepper',
'switcher',
'slider',
'repeater',
'iconpicker',
'button',
'dimensions',
),
);
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public static $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
public static $module_path;
/**
* Constructor.
*
* @since 1.0.0
* @param object $core Core.
* @param array $args Arguments.
*/
public function __construct( $core, $args ) {
$this->args = array_merge( $this->args, $args );
self::$core_version = $core->get_core_version();
self::$module_path = $args['module_path'];
$this->ui_elements_require();
// Load admin assets.
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
}
/**
* Get UI-element instance.
*
* @since 1.0.0
* @param [type] $ui_slug ui element.
* @param array $args arguments.
* @return object
*/
public function get_ui_element_instance( $ui_slug, $args ) {
if ( empty( $ui_slug ) ) {
echo '<p>Set an empty slug</p>';
return false;
}
if ( ! in_array( $ui_slug, $this->args['ui_elements'] ) ) {
echo '<p> Element <b>' . $ui_slug . '</b> has not been initialized in this instance!</p>';
return false;
}
$ui_class_name = 'UI_' . ucwords( $ui_slug );
if ( ! class_exists( $ui_class_name ) ) {
echo '<p>Class <b>' . $ui_class_name . '</b> not exist!</p>';
return false;
}
return new $ui_class_name( $args );
}
/**
* Require UI-elements.
*
* @since 1.0.0
* @return void
*/
public function ui_elements_require() {
// Add I_UI interface.
if ( ! interface_exists( 'I_UI' ) ) {
require_once( self::$module_path . 'i-ui.php' );
}
require_once( self::$module_path. 'ui-element.php' );
require_once( self::$module_path . 'inc/class-cherry-lock-element.php' );
if ( ! empty( $this->args['ui_elements'] ) ) {
foreach ( $this->args['ui_elements'] as $ui_element ) {
require_once( self::$module_path . 'inc/ui-elements/ui-' . $ui_element . '/ui-' . $ui_element . '.php' );
}
}
}
/**
* Load admin assets.
*
* @since 1.0.0
*/
public function enqueue_admin_assets() {
if ( ! empty( $this->args['ui_elements'] ) ) {
foreach ( $this->args['ui_elements'] as $ui_element ) {
$ui_class_name = 'UI_' . ucwords( $ui_element );
call_user_func( array( $ui_class_name, 'enqueue_assets' ) );
}
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* I'am UI interface
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
/**
* UI element interface
*/
interface I_UI {
/**
* Enqueue javascript and stylesheet to UI element.
*/
public static function enqueue_assets();
/**
* Render UI element.
*
* @return string.
*/
public function render();
/**
* Get control name
*
* @return string control name.
*/
public function get_name();
/**
* Set control name
*
* @param [type] $name new control name.
*/
public function set_name( $name );
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Class lock the elements
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If class `Cherry5_Lock_Element` doesn't exists yet.
if ( ! class_exists( 'Cherry5_Lock_Element' ) ) {
/**
* Cherry5_Lock_Element class.
*/
class Cherry5_Lock_Element {
/**
* Default settings.
*
* @since 1.4.3
* @access private
* @var array
*/
private $defaults_args = array();
/**
* The attributes of the class.
*
* @since 1.4.3
* @access private
* @var array
*/
private $args = array();
/**
* The status of locked element.
*
* @since 1.4.3
* @access private
* @var bool
*/
private $element_lock = false;
/**
* Constructor method for the class.
*
* @since 1.4.3
* @access public
* @return void
*/
public function __construct( $args = array() ) {
if ( ! is_array( $args ) || empty( $args ) || empty( $args['lock'] ) ) {
return false;
}
$this->element_lock = true;
$this->defaults_args = apply_filters( 'cherry5_lock_element_defaults', array(
'label' => esc_html__( 'Unlocked in PRO', 'cherry-framework' ),
'url' => '#',
'html' => '<a class="cherry-lock-element__area" target="_blank" href="%1$s" title="%3$s"><span class="cherry-lock-element__label">%2$s %3$s</span></a>',
'icon' => '<i class="fa fa-unlock-alt" aria-hidden="true"></i>',
'class' => 'cherry-lock-element',
), $args );
$this->args = wp_parse_args( $args['lock'], $this->defaults_args );
}
/**
* Return lock element HTML-class.
*
* @since 1.4.3
* @access public
* @return string
*/
public function get_class( $sub_class = '' ) {
if ( ! $this->element_lock ) {
return '';
}
$classes = array(
$this->args['class'],
$sub_class,
);
$classes = array_filter( $classes );
$classes = array_map( 'esc_attr', $classes );
return ' ' . join( ' ', $classes );
}
/**
* Return disabled attribute.
*
* @since 1.4.3
* @access public
* @return string
*/
public function get_disabled_attr() {
return $this->element_lock ? ' disabled' : '';
}
/**
* Return lock element HTML-markup.
*
* @since 1.4.3
* @access public
* @return string
*/
public function get_html() {
if ( ! $this->element_lock ) {
return '';
}
return sprintf( $this->args['html'],
esc_url( $this->args['url'] ),
$this->args['icon'],
esc_attr( $this->args['label'] )
);
}
}
}

View File

@@ -0,0 +1 @@
.cherry5-ui-button{position:relative;display:inline-block;font-size:11px;line-height:18px;text-decoration:none;padding:4px 22px;color:#23282d;text-transform:uppercase;border-radius:4px;border-width:1px;border-style:solid;outline:none;cursor:pointer;transition:all 200ms linear}.cherry5-ui-button:before{position:absolute;display:block;width:100%;height:100%;top:0;left:0;border-radius:4px;background-image:linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);content:''}.cherry5-ui-button:hover:before{background-image:linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%)}.cherry5-ui-button:active:before{opacity:0}.cherry5-ui-button.cherry5-ui-button-normal-style{color:#23282d;border-color:#d7d7d7 #b7b7b7 #b7b7b7 #d7d7d7;background-color:#f0f0f0}.cherry5-ui-button.cherry5-ui-button-normal-style:active{background-color:#e1e1e1;border-color:#9e9e9e #d7d7d7 #d7d7d7 #9e9e9e}.cherry5-ui-button.cherry5-ui-button-success-style{color:#fff;border-color:#49c56a #3a9e54 #3a9e54 #49c56a;background-color:#49c66a}.cherry5-ui-button.cherry5-ui-button-success-style:active{background-color:#3ba956;border-color:#2c7940 #49c56a #49c56a #2c7940}.cherry5-ui-button.cherry5-ui-button-primary-style{color:#fff;border-color:#5b9add #3e6a99 #3e6a99 #5b9add;background-color:#2a90fc}.cherry5-ui-button.cherry5-ui-button-primary-style:active{background-color:#206ff4;border-color:#2f5175 #5b9add #5b9add #2f5175}.cherry5-ui-button.cherry5-ui-button-secondary-style{color:#fff;border-color:#777879 #41464d #41464d #777879;background-color:#495159}.cherry5-ui-button.cherry5-ui-button-secondary-style:active{background-color:#495159;border-color:#2a2d31 #777879 #777879 #2a2d31}.cherry5-ui-button.cherry5-ui-button-danger-style{color:#fff;border-color:#e54444 #b83636 #b83636 #e54444;background-color:#e64545}.cherry5-ui-button.cherry5-ui-button-danger-style:active{background-color:#c73434;border-color:#912a2a #e54444 #e54444 #912a2a}.cherry5-ui-button.cherry5-ui-button-warning-style{color:#fff;border-color:#faa832 #c98627 #c98627 #faa832;background-color:#faa832}.cherry5-ui-button.cherry5-ui-button-warning-style:active{background-color:#ee8425;border-color:#9e6a1f #faa832 #faa832 #9e6a1f}

View File

@@ -0,0 +1,66 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
.cherry5-ui-button{
@include button_base();
&.cherry5-ui-button-normal-style {
color: $dark_color;
border-color: $normal_outset_1 $normal_outset_2 $normal_outset_2 $normal_outset_1;
background-color: $normal_gradint_2;
&:active {
background-color: $normal_bg_color;
border-color: darken( $normal_outset_2, 10%) $normal_outset_1 $normal_outset_1 darken( $normal_outset_2, 10%);
}
}
&.cherry5-ui-button-success-style {
color: $light_color;
border-color: $success_outset_1 $success_outset_2 $success_outset_2 $success_outset_1;
background-color: $success_gradint_2;
&:active {
background-color: $success_bg_color;
border-color: darken( $success_outset_2, 10%) $success_outset_1 $success_outset_1 darken( $success_outset_2, 10%);
}
}
&.cherry5-ui-button-primary-style {
color: $light_color;
border-color: $primary_outset_1 $primary_outset_2 $primary_outset_2 $primary_outset_1;
background-color: $primary_gradint_2;
&:active {
background-color: $primary_bg_color;
border-color: darken( $primary_outset_2, 10%) $primary_outset_1 $primary_outset_1 darken( $primary_outset_2, 10%);
}
}
&.cherry5-ui-button-secondary-style {
color: $light_color;
border-color: $secondary_outset_1 $secondary_outset_2 $secondary_outset_2 $secondary_outset_1;
background-color: $secondary_gradint_2;
&:active {
background-color: $secondary_bg_color;
border-color: darken( $secondary_outset_2, 10%) $secondary_outset_1 $secondary_outset_1 darken( $secondary_outset_2, 10%);
}
}
&.cherry5-ui-button-danger-style{
color: $light_color;
border-color: $danger_outset_1 $danger_outset_2 $danger_outset_2 $danger_outset_1;
background-color: $danger_gradint_2;
&:active {
background-color: $danger_bg_color;
border-color: darken( $danger_outset_2, 10%) $danger_outset_1 $danger_outset_1 darken( $danger_outset_2, 10%);
}
}
&.cherry5-ui-button-warning-style{
color: $light_color;
border-color: $warning_outset_1 $warning_outset_2 $warning_outset_2 $warning_outset_1;
background-color: $warning_gradint_2;
&:active {
background-color: $warning_bg_color;
border-color: darken( $warning_outset_2, 10%) $warning_outset_1 $warning_outset_1 darken( $warning_outset_2, 10%);
}
}
}

View File

@@ -0,0 +1,40 @@
@mixin button_base() {
position: relative;
display: inline-block;
font-size: 11px;
line-height: 18px;
text-decoration: none;
padding: 4px 22px;
color: $dark_color;
text-transform: uppercase;
border-radius: $border_radius_small;
border-width: 1px;
border-style: solid;
outline: none;
cursor: pointer;
transition: all 200ms linear;
&:before {
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: $border_radius_small;
background-image: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
content: '';
}
&:hover {
&:before {
background-image: linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
}
}
&:active {
&:before {
opacity: 0;
}
}
}

View File

@@ -0,0 +1,46 @@
$light_color: #ffffff;
$dark_color: #23282d;
$normal_bg_color: #e1e1e1;
$normal_gradint_1: #ffffff;
$normal_gradint_2: #f0f0f0;
$normal_outset_1: #d7d7d7;
$normal_outset_2: #b7b7b7;
$primary_bg_color: #206ff4;
$primary_gradint_1: #5fadff;
$primary_gradint_2: #2a90fc;
$primary_outset_1: #5b9add;
$primary_outset_2: #3e6a99;
$secondary_bg_color: #495159;
$secondary_gradint_1: #4c5054;
$secondary_gradint_2: #495159;
$secondary_outset_1: #777879;
$secondary_outset_2: #41464d;
$success_bg_color: #3ba956;
$success_gradint_1: #71e18f;
$success_gradint_2: #49c66a;
$success_outset_1: #49c56a;
$success_outset_2: #3a9e54;
$danger_bg_color: #c73434;
$danger_gradint_1: #f98888;
$danger_gradint_2: #e64545;
$danger_outset_1: #e54444;
$danger_outset_2: #b83636;
$warning_bg_color: #ee8425;
$warning_gradint_1: #ffcb81;
$warning_gradint_2: #faa832;
$warning_outset_1: #faa832;
$warning_outset_2: #c98627;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,86 @@
<?php
/**
* Class for the building ui-button elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Button' ) ) {
/**
* Class for the building ui-button elements.
*/
class UI_Button extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'id' => 'cherry-ui-button-id',
'name' => 'cherry-ui-button-name',
'value' => 'button',
'disabled' => false,
'form' => '',
'formaction' => '',
'button_type' => 'button',
'style' => 'normal',
'content' => 'Button',
'class' => '',
'master' => '',
);
/**
* Constructor method for the UI_Button class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-button-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Render html UI_Button.
*
* @since 1.0.0
*/
public function render() {
$html = Cherry_Toolkit::render_view(
Cherry_UI_Elements::$module_path . 'inc/ui-elements/ui-button/view/button-view.php',
$this->settings
);
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Button.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_style(
'ui-button',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-button/assets/min/ui-button.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Ui-Button view
*
* @package Cherry_UI_Elements
* @subpackage View
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
$classes = array( 'cherry5-ui-button', 'cherry5-ui-button-' . $__data['style'] . '-style', $__data['master'], $__data['class'], 'ui-button' );
$classes = array_filter( $classes );
$class = trim( implode( ' ', $classes ) );
$attrs = Cherry_Toolkit::join(
array(
'type' => esc_attr( $__data['button_type'] ),
'id' => esc_attr( $__data['id'] ),
'name' => esc_attr( $__data['name'] ),
'class' => esc_attr( $class ),
'form' => esc_attr( $__data['form'] ),
'formaction' => esc_attr( $__data['formaction'] ),
)
);
if ( filter_var( $__data['disabled'], FILTER_VALIDATE_BOOLEAN ) ) {
$attrs .= ' disabled';
}
?>
<button <?php echo $attrs; ?>><?php echo $__data['content']; ?></button>

View File

@@ -0,0 +1 @@
.cherry-lock-element{user-select:none;cursor:no-drop;position:relative;filter:grayscale(100%)}.cherry-lock-element.inline-block{display:inline-block}.cherry-lock-element label{position:relative}.cherry-lock-element .cherry-lable-content,.cherry-lock-element .cherry-checkbox-item,.cherry-lock-element .select2-container,.cherry-lock-element>*:first-child{opacity:0.5;pointer-events:none}.cherry-lock-element a.cherry-lock-element__area{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2000;cursor:no-drop}.cherry-lock-element a.cherry-lock-element__area:focus{outline:none;box-shadow:none}.cherry-lock-element a.cherry-lock-element__area:hover .cherry-lock-element__label{animation-name:lock_show;animation-duration:450ms;animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1)}.cherry-lock-element__label{opacity:0;display:inline-block;background-color:rgba(0,0,0,0.9);border-radius:5px;color:#fff;padding:8px 10px;position:absolute;white-space:nowrap;top:-10px;left:50%;box-shadow:2px 2px 5px 0px rgba(0,0,0,0.5);will-change:auto;pointer-events:none;font-size:14px;line-height:16px;animation-name:lock_hide;animation-duration:200ms;animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);animation-fill-mode:both;transform-origin:0% 0%}.cherry-lock-element__label *+*{margin-right:5px}.cherry-lock-element__label:after{border:solid;border-color:rgba(0,0,0,0.9) transparent;border-width:6px 6px 0 6px;bottom:-5px;margin-left:-6px;content:"";left:50%;position:absolute}@keyframes lock_show{0%{opacity:0;filter:blur(5px);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}}@keyframes lock_hide{0%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;filter:blur(3px);transform:scale(0) translate(-50%, 200%)}}.cherry-ui-container{margin:10px 0 20px 0}label.cherry-label{margin:0 0 5px 0;display:block}.hide{display:none !important}.cherry-checkbox-item{width:20px;height:20px;display:inline-block;border-radius:2px;margin-right:10px;margin-bottom:10px;cursor:pointer;position:relative;background-color:#f1f1f1;user-select:none;transition:all 0.4s cubic-bezier(0.77, 0, 0.175, 1)}.cherry-checkbox-item .marker{position:absolute;width:20px;height:20px;top:0px;left:0px;color:#fff;font-size:20px;transition:inherit;transform:scale(0)}.cherry-checkbox-item .marker:before{transition:inherit;position:relative;left:-1px}.cherry-lable-content{display:flex}.cherry-checkbox-input[checked]+.cherry-checkbox-item{background-color:#48c569}.cherry-checkbox-input[checked]+.cherry-checkbox-item .marker{transform:scale(1)}.cherry-checkbox-label{font-size:12px;line-height:20px;color:#23282d;user-select:none}.cherry-checkbox-label:focus{outline:1px solid rgba(41,143,252,0.6);box-shadow:0px 0px 2px rgba(41,143,252,0.6)}

View File

@@ -0,0 +1 @@
!function(e,t){"use strict";t.utilites.namespace("ui_elements.checkbox"),t.ui_elements.checkbox={inputClass:'.cherry-checkbox-input[type="hidden"]:not([name*="__i__"])',labelClass:".cherry-checkbox-label, .cherry-checkbox-item",init:function(){e(document).on("ready.cherry-ui-elements-init",this.addEvent.bind(this)).on("cherry-ui-elements-init",this.initState.bind(this))},addEvent:function(){e("body").on("click.masterSlave",this.labelClass,this.switchState.bind(this)),this.initState()},initState:function(){for(var t,i,s,n=e(this.inputClass),c=n.length-1;c>=0;c--)t=e(n[c]),i=t.data(),s=t.closest("form"),jQuery.isEmptyObject(i)||e("."+i.slave,s)[t[0].checked?"removeClass":"addClass"]("hide")},switchState:function(t){var i=e(t.currentTarget).siblings(this.inputClass),s=i.data(),n=i[0].checked,c=i.closest("form");i.val(n?"false":"true").attr("checked",!n).trigger("change"),jQuery.isEmptyObject(s)||e("."+s.slave,c)[n?"addClass":"removeClass"]("hide")}},t.ui_elements.checkbox.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,58 @@
/**
* Checkbox
*/
( function( $, CherryJsCore ) {
'use strict';
CherryJsCore.utilites.namespace('ui_elements.checkbox');
CherryJsCore.ui_elements.checkbox = {
inputClass: '.cherry-checkbox-input[type="hidden"]:not([name*="__i__"])',
labelClass: '.cherry-checkbox-label, .cherry-checkbox-item',
init: function() {
$( document )
.on( 'ready.cherry-ui-elements-init', this.addEvent.bind( this ) )
.on( 'cherry-ui-elements-init', this.initState.bind( this ) );
},
addEvent: function() {
$( 'body' ).on( 'click.masterSlave', this.labelClass, this.switchState.bind( this ) );
this.initState();
},
initState: function(){
var $_input = $( this.inputClass ),
i = $_input.length - 1,
$_target,
data,
wrapper;
for ( ; i >= 0; i-- ) {
$_target = $( $_input[ i ] );
data = $_target.data();
wrapper = $_target.closest('form');
if ( jQuery.isEmptyObject( data ) ) {
continue;
} else {
$( '.' + data.slave, wrapper )[ ( $_target[0].checked ) ? 'removeClass' : 'addClass' ]( 'hide' );
}
}
},
switchState: function( event ) {
var $_input = $( event.currentTarget ).siblings( this.inputClass ),
data = $_input.data(),
flag = $_input[0].checked,
wrapper = $_input.closest('form');
$_input
.val( ( flag ) ? 'false' : 'true' )
.attr( 'checked', ( flag ) ? false : true )
.trigger( 'change' );
if ( ! jQuery.isEmptyObject( data ) ) {
$( '.' + data.slave, wrapper )[ ( flag ) ? 'addClass' : 'removeClass' ]( 'hide' );
}
}
};
CherryJsCore.ui_elements.checkbox.init();
} ( jQuery, window.CherryJsCore ) );

View File

@@ -0,0 +1,69 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
.cherry-ui-container{
margin: 10px 0 20px 0;
}
label.cherry-label{
margin: 0 0 5px 0;
display: block;
}
.hide{
display: none !important;
}
.cherry-checkbox-item{
width: 20px;
height: 20px;
display: inline-block;
border-radius: $border_radius_extra_small;
margin-right: 10px;
margin-bottom: 10px;
cursor: pointer;
position: relative;
background-color: $grey_color_3;
user-select: none;
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
.marker{
position: absolute;
width: 20px;
height: 20px;
top: 0px;
left: 0px;
color: #fff;
font-size: 20px;
transition:inherit;
transform: scale(0);
&:before{
transition:inherit;
position: relative;
left: -1px;
}
}
}
.cherry-lable-content {
display: flex;
}
.cherry-checkbox-input{
&[checked]{
&+.cherry-checkbox-item{
background-color: $green_color;
.marker{
transform: scale(1);
}
}
}
}
.cherry-checkbox-label{
font-size: 12px;
line-height: 20px;
color: $dark_color_1;
user-select: none;
&:focus{
outline: 1px solid rgba(41, 143, 252, .6);
box-shadow: 0px 0px 2px rgba(41,143,252,0.6);
}
}

View File

@@ -0,0 +1,184 @@
@mixin button_base() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
padding: 15px 20px;
color: #fff;
text-transform: uppercase;
border-radius: $border_radius_small;
transition: all 200ms linear;
box-shadow: $box_shadow;
&:hover {
color: #fff;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: #fff;
}
}
@mixin button_normal() {
background: $dark_color_2;
&:hover {
background: $dark_color_2_h;
}
}
@mixin button_primary() {
background: $blue_color;
&:hover {
background: $blue_color_h;
}
}
@mixin button_success() {
background: $green_color;
&:hover {
background: $green_color_h;
}
}
@mixin button_danger() {
background: $red_color;
&:hover {
background: $red_color_h;
}
}
@mixin button_warning() {
background: $orange_color;
&:hover {
background: $orange_color_h;
}
}
@mixin input() {
font-size: 14px;
line-height: 20px;
color: $dark_color_1;
background-color: $grey_color_3;
border-radius: $border_radius_extra_small;
padding: 10px 20px;
min-height: 50px;
border: 1px solid $grey_color_3;
box-shadow: none;
&:focus{
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
}
}
@mixin button_icon( $icon ) {
content: $icon;
display: inline-block;
font-family: dashicons;
font-size: 16px;
font-style: normal;
font-weight: 400;
height: 18px;
line-height: 18px;
text-align: center;
text-decoration: inherit;
transition: all 200ms linear;
vertical-align: middle;
}
@mixin button_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
}
}
@mixin button_icon_after( $icon ) {
&:after {
@include button_icon( $icon );
padding: 0 0 0 5px;
}
}
@mixin button_icon_middle( $icon ) {
&:before {
@include button_icon( $icon );
margin: 0 -5px;
}
}
@mixin link() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
color: $blue_color;
text-transform: uppercase;
transition: all 200ms linear;
&:hover {
color: $dark_color_1;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: $blue_color;
}
}
@mixin link_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
color: $grey_color_4;
}
&:hover {
&:before {
color: $blue_color;
}
}
}
@mixin container() {
padding: 30px;
border: 2px solid $grey_color_2;
background: $grey_color_3;
border-radius: $border_radius_large;
}
@mixin container_heading() {
margin: -30px -30px 30px -30px;
border-radius: $border_radius_large $border_radius_large 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
text-align: center;
background: #fff;
}
@mixin box() {
margin: 0 0 30px;
padding: 20px;
background: #fff;
box-shadow: $box_shadow_box;
border-radius: $border_radius;
}
@mixin box_heading() {
margin: -20px -20px 20px -20px;
border-radius: $border_radius_small $border_radius_small 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
background: #fff;
}

View File

@@ -0,0 +1,23 @@
$dark_color_1: #23282d;
$dark_color_2: #495159;
$dark_color_2_h: #393f45;
$grey_color_1: #96989a;
$grey_color_2: #e5e5e5;
$grey_color_3: #f1f1f1;
$grey_color_4: #b4b7ba;
$blue_color: #298ffc;
$blue_color_h: #206ff4;
$green_color: #48c569;
$green_color_h: #3ba956;
$red_color: #e54343;
$red_color_h: #c73434;
$orange_color: #faa730;
$orange_color_h: #ee8425;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,154 @@
<?php
/**
* Class for the building ui-checkbox elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Checkbox' ) ) {
/**
* Class for the building UI_Checkbox elements.
*/
class UI_Checkbox extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'id' => 'cherry-ui-checkbox-id',
'name' => 'cherry-ui-checkbox-name',
'value' => array(
'checkbox-1' => 'true',
'checkbox-2' => 'true',
'checkbox-3' => 'true',
),
'options' => array(
'checkbox-1' => 'checkbox 1',
'checkbox-2' => 'checkbox 2',
'checkbox-3' => 'checkbox 3',
),
'label' => '',
'class' => '',
'master' => '',
);
/**
* Instance of this Cherry5_Lock_Element class.
*
* @since 1.0.0
* @var object
* @access private
*/
private $lock_element = null;
/**
* Constructor method for the UI_Checkbox class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-checkbox-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->lock_element = new Cherry5_Lock_Element( $this->settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Render html UI_Checkbox.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['master'],
$this->lock_element->get_class( 'inline-block' ),
)
);
$html .= '<div class="cherry-ui-container ' . esc_attr( $class ) . '">';
$counter = 0;
if ( $this->settings['options'] && ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
if ( ! is_array( $this->settings['value'] ) ) {
$this->settings['value'] = array( $this->settings['value'] );
}
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
foreach ( $this->settings['options'] as $option => $option_value ) {
$lock_option = new Cherry5_Lock_Element( $option_value );
if ( ! empty( $this->settings['value'] ) ) {
$option_checked = array_key_exists( $option, $this->settings['value'] ) ? $option : '';
$item_value = ! empty( $option_checked ) ? $this->settings['value'][ $option ] : 'false';
} else {
$option_checked = '';
$item_value = 'false';
}
$checked = ( ! empty( $option_checked ) && 'true' === $item_value ) ? 'checked' : '';
$option_label = isset( $option_value ) && is_array( $option_value ) ? $option_value['label'] : $option_value;
$data_slave = isset( $option_value['slave'] ) && ! empty( $option_value['slave'] ) ? ' data-slave="' . $option_value['slave'] . '"' : '';
$html .= '<div class="cherry-checkbox-item-wrap">';
$html .= '<span class="' . $lock_option->get_class( 'inline-block' ) . '"">';
$html .= '<span class="cherry-lable-content">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '" class="cherry-checkbox-input" name="' . esc_attr( $this->settings['name'] ) . '[' . $option . ']" ' . $checked . ' value="' . esc_html( $item_value ) . '"' . $data_slave . $lock_option->get_disabled_attr() . '>';
$html .= '<div class="cherry-checkbox-item"><span class="marker dashicons dashicons-yes"></span></div>';
$html .= '<label class="cherry-checkbox-label" for="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '"><span class="cherry-lable-content">' . esc_html( $option_label ) . '</span></label> ';
$html .= '</span>';
$html .= $lock_option->get_html();
$html .= '</span>';
$html .= '</div>';
$counter++;
}
}
$html .= $this->lock_element->get_html() . '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Checkbox.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_script(
'ui-checkbox',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-checkbox/assets/min/ui-checkbox.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_style(
'ui-checkbox',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-checkbox/assets/min/ui-checkbox.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1 @@
.cherry-lock-element{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:no-drop;position:relative;-webkit-filter:grayscale(100%);filter:grayscale(100%)}.cherry-lock-element.inline-block{display:inline-block}.cherry-lock-element label{position:relative}.cherry-lock-element .cherry-lable-content,.cherry-lock-element .cherry-checkbox-item,.cherry-lock-element .select2-container,.cherry-lock-element>*:first-child{opacity:0.5;pointer-events:none}.cherry-lock-element a.cherry-lock-element__area{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2000;cursor:no-drop}.cherry-lock-element a.cherry-lock-element__area:focus{outline:none;box-shadow:none}.cherry-lock-element a.cherry-lock-element__area:hover .cherry-lock-element__label{-webkit-animation-name:lock_show;animation-name:lock_show;-webkit-animation-duration:450ms;animation-duration:450ms;-webkit-animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1);animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1)}.cherry-lock-element__label{opacity:0;display:inline-block;background-color:rgba(0,0,0,0.9);border-radius:5px;color:#fff;padding:8px 10px;position:absolute;white-space:nowrap;top:-10px;left:50%;box-shadow:2px 2px 5px 0px rgba(0,0,0,0.5);will-change:auto;pointer-events:none;font-size:14px;line-height:16px;-webkit-animation-name:lock_hide;animation-name:lock_hide;-webkit-animation-duration:200ms;animation-duration:200ms;-webkit-animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-transform-origin:0% 0%;-ms-transform-origin:0% 0%;transform-origin:0% 0%}.cherry-lock-element__label *+*{margin-right:5px}.cherry-lock-element__label:after{border:solid;border-color:rgba(0,0,0,0.9) transparent;border-width:6px 6px 0 6px;bottom:-5px;margin-left:-6px;content:"";left:50%;position:absolute}@-webkit-keyframes lock_show{0%{opacity:0;-webkit-filter:blur(5px);filter:blur(5px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;-webkit-transform:scale(1.1) translate(-50%, -130%);transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}}@keyframes lock_show{0%{opacity:0;-webkit-filter:blur(5px);filter:blur(5px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;-webkit-transform:scale(1.1) translate(-50%, -130%);transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}}@-webkit-keyframes lock_hide{0%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;-webkit-filter:blur(3px);filter:blur(3px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}}@keyframes lock_hide{0%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;-webkit-filter:blur(3px);filter:blur(3px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}}.cherry-ui-elements-lock{opacity:0.5;cursor:no-drop;pointer-events:none;-webkit-filter:grayscale(100%);filter:grayscale(100%)}.cherry-ui-container{margin:10px 0 20px 0}label.cherry-label{margin:0 0 5px 0;display:block}.cherry-ui-colorpicker-wrapper .wp-picker-container{padding:3px;border-radius:3px}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result-text{line-height:18px;text-align:right}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result{width:105px;height:26px;padding:0;border:none;margin:0;box-shadow:inset 0 0 0 3px white;border:1px solid #d5dadf}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result:focus{border:1px solid #9ba7b3;outline:none}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result:after{display:none}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-picker-input-wrap{margin:1px 0}.cherry-ui-colorpicker-wrapper .wp-picker-container.wp-picker-active .wp-color-result{margin-right:6px}.cherry-ui-colorpicker-wrapper .wp-picker-container .iris-picker{position:absolute;z-index:999}

View File

@@ -0,0 +1 @@
!function(e,r){"use strict";r.utilites.namespace("ui_elements.colorpicker"),r.ui_elements.colorpicker={init:function(){e(document).on("ready",this.render).on("cherry-ui-elements-init",this.render)},render:function(r){var i=r._target?r._target:e("body"),n=e('input.cherry-ui-colorpicker:not([name*="__i__"])',i);n[0]&&n.wpColorPicker()}},r.ui_elements.colorpicker.init()}(jQuery,window.CherryJsCore);

Some files were not shown because too many files have changed in this diff Show More