/* * jQuery.appear * https://github.com/bas2k/jquery.appear/ * http://code.google.com/p/jquery-appear/ * http://bas2k.ru/ * * Copyright (c) 2009 Michael Hixson * Copyright (c) 2012-2014 Alexander Brovikov * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) */ ( function( $ ) { 'use strict'; $.fn.appear = function( fn, options ) { var settings = $.extend( { //arbitrary data to pass to fn data: undefined, //call fn only on the first appear? one: true, // X & Y accuracy accX: 0, accY: 0 }, options ); return this.each( function() { var t = $( this ); //whether the element is currently visible t.appeared = false; if ( !fn ) { //trigger the custom event t.trigger( 'appear', settings.data ); return; } var w = $( window ); var _demos = $( '#theme-install-demos' ); //fires the appear event when appropriate var check = function() { //is the element hidden? if ( !t.is( ':visible' ) ) { //it became hidden t.appeared = false; return; } //is the element inside the visible window? var a = w.scrollLeft(); var b = w.scrollTop(); var o = t.offset(); var x = o.left; var y = o.top; var ax = settings.accX; var ay = settings.accY; var th = t.height(); var wh = w.height(); var tw = t.width(); var ww = w.width(); if ( y + th + ay >= b && y <= b + wh + ay && x + tw + ax >= a && x <= a + ww + ax ) { //trigger the custom event if ( !t.appeared ) t.trigger( 'appear', settings.data ); } else { //it scrolled out of view t.appeared = false; } }; //create a modified fn with some additional logic var modifiedFn = function() { //mark the element as visible t.appeared = true; //is this supposed to happen only once? if ( settings.one ) { //remove the check w.off( 'scroll', check ); _demos.off( 'scroll', check ); var i = $.inArray( check, $.fn.appear.checks ); if ( i >= 0 ) $.fn.appear.checks.splice( i, 1 ); } //trigger the original fn fn.apply( this, arguments ); }; //bind the modified fn to the element if ( settings.one ) t.one( 'appear', settings.data, modifiedFn ); else t.on( 'appear', settings.data, modifiedFn ); //check whenever the window scrolls w.scroll( check ); _demos.scroll( check ); //check whenever the dom changes $.fn.appear.checks.push( check ); //check now ( check )(); } ); }; //keep a queue of appearance checks $.extend( $.fn.appear, { checks: [], timeout: null, //process the queue checkAll: function() { var length = $.fn.appear.checks.length; if ( length > 0 ) while ( length-- ) { if ( typeof $.fn.appear.checks[length] == 'function' ) ( $.fn.appear.checks[length] )(); } }, //check the queue asynchronously run: function() { if ( $.fn.appear.timeout ) clearTimeout( $.fn.appear.timeout ); $.fn.appear.timeout = setTimeout( $.fn.appear.checkAll, 20 ); } } ); //run checks when these methods are called /*$.each(['append', 'prepend', 'after', 'before', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'remove', 'css', 'show', 'hide'], function(i, n) { var old = $.fn[n]; if (old) { $.fn[n] = function() { var r = old.apply(this, arguments); $.fn.appear.run(); return r; } } });*/ } )( jQuery ); // Easy Responsive Tabs Plugin // Author: Samson.Onna ( function( $ ) { 'use strict'; $.fn.extend( { easyResponsiveTabs: function( options ) { //Set the default values, use comma to separate the settings, example: var defaults = { type: 'default', //default, vertical, accordion; width: 'auto', fit: true, closed: false, activate: function() { } } //Variables options = $.extend( defaults, options ); var opt = options, jtype = opt.type, jfit = opt.fit, jwidth = opt.width, vtabs = 'vertical', accord = 'accordion'; var hash = window.location.hash; var historyApi = !!( window.history && history.replaceState ); //Events $( this ).on( 'tabactivate', function( e, currentTab ) { if ( typeof options.activate === 'function' ) { options.activate.call( currentTab, e ); } } ); //Main function this.each( function() { var $respTabs = $( this ); var $respTabsList = $respTabs.find( 'ul.resp-tabs-list' ); var respTabsId = $respTabs.attr( 'id' ); $respTabs.find( 'ul.resp-tabs-list li' ).addClass( 'resp-tab-item' ); $respTabs.css( { 'display': 'block', 'width': jwidth } ); $respTabs.find( '.resp-tabs-container > div' ).addClass( 'resp-tab-content' ); jtab_options(); //Properties Function function jtab_options() { if ( jtype == vtabs ) { $respTabs.addClass( 'resp-vtabs' ); } if ( jfit == true ) { $respTabs.css( { width: '100%' } ); } if ( jtype == accord ) { $respTabs.addClass( 'resp-easy-accordion' ); $respTabs.find( '.resp-tabs-list' ).css( 'display', 'none' ); } } //Assigning the h2 markup to accordion title var $tabItemh2; $respTabs.find( '.resp-tab-content' ).before( "" ); var itemCount = 0; $respTabs.find( '.resp-accordion' ).each( function() { $tabItemh2 = $( this ); var $tabItem = $respTabs.find( '.resp-tab-item:eq(' + itemCount + ')' ); var $accItem = $respTabs.find( '.resp-accordion:eq(' + itemCount + ')' ); $accItem.append( $tabItem.html() ); $accItem.data( $tabItem.data() ); $tabItemh2.attr( 'aria-controls', 'tab_item-' + ( itemCount ) ); itemCount++; } ); //Assigning the 'aria-controls' to Tab items var count = 0, $tabContent; $respTabs.find( '.resp-tab-item' ).each( function() { var $tabItem = $( this ); $tabItem.attr( 'aria-controls', 'tab_item-' + ( count ) ); $tabItem.attr( 'role', 'tab' ); //Assigning the 'aria-labelledby' attr to tab-content var tabcount = 0; $respTabs.find( '.resp-tab-content' ).each( function() { $tabContent = $( this ); $tabContent.attr( 'aria-labelledby', 'tab_item-' + ( tabcount ) ); tabcount++; } ); count++; } ); // Show correct content area var tabNum = 0; if ( hash != '' ) { var matches = hash.match( new RegExp( respTabsId + "([0-9]+)" ) ); if ( matches !== null && matches.length === 2 ) { tabNum = parseInt( matches[1], 10 ) - 1; if ( tabNum > count ) { tabNum = 0; } } } //Active correct tab $( $respTabs.find( '.resp-tab-item' )[tabNum] ).addClass( 'resp-tab-active' ); //keep closed if option = 'closed' or option is 'accordion' and the element is in accordion mode if ( options.closed !== true && !( options.closed === 'accordion' && !$respTabsList.is( ':visible' ) ) && !( options.closed === 'tabs' && $respTabsList.is( ':visible' ) ) ) { $( $respTabs.find( '.resp-accordion' )[tabNum] ).addClass( 'resp-tab-active' ); $( $respTabs.find( '.resp-tab-content' )[tabNum] ).addClass( 'resp-tab-content-active' ).attr( 'style', 'display:block' ); } //assign proper classes for when tabs mode is activated before making a selection in accordion mode else { $( $respTabs.find( '.resp-tab-content' )[tabNum] ).addClass( 'resp-tab-content-active resp-accordion-closed' ); } //Tab Click action function $respTabs.find( "[role=tab]" ).each( function() { var $currentTab = $( this ); $currentTab.on( 'click', function() { var $currentTab = $( this ); var $tabAria = $currentTab.attr( 'aria-controls' ); if ( $currentTab.hasClass( 'resp-accordion' ) && $currentTab.hasClass( 'resp-tab-active' ) ) { $respTabs.find( '.resp-tab-content-active' ).slideUp( '', function() { $( this ).addClass( 'resp-accordion-closed' ); } ); $currentTab.removeClass( 'resp-tab-active' ); return false; } if ( !$currentTab.hasClass( 'resp-tab-active' ) && $currentTab.hasClass( 'resp-accordion' ) ) { $respTabs.find( '.resp-tab-active' ).removeClass( 'resp-tab-active' ); $respTabs.find( '.resp-tab-content-active' ).slideUp().removeClass( 'resp-tab-content-active resp-accordion-closed' ); $respTabs.find( "[aria-controls=" + $tabAria + "]" ).addClass( 'resp-tab-active' ); $respTabs.find( '.resp-tab-content[aria-labelledby = ' + $tabAria + ']' ).slideDown().addClass( 'resp-tab-content-active' ); } else { $respTabs.find( '.resp-tab-active' ).removeClass( 'resp-tab-active' ); $respTabs.find( '.resp-tab-content-active' ).removeAttr( 'style' ).removeClass( 'resp-tab-content-active' ).removeClass( 'resp-accordion-closed' ); $respTabs.find( "[aria-controls=" + $tabAria + "]" ).addClass( 'resp-tab-active' ); $respTabs.find( '.resp-tab-content[aria-labelledby = ' + $tabAria + ']' ).addClass( 'resp-tab-content-active' ).attr( 'style', 'display:block' ); } //Trigger tab activation event $currentTab.trigger( 'tabactivate', $currentTab ); } ); } ); //Window resize function $( window ).on( 'resize', function() { $respTabs.find( '.resp-accordion-closed' ).removeAttr( 'style' ); } ); } ); } } ); } )( jQuery ); jQuery( document ).ready( function( $ ) { 'use strict'; // content type meta tab $( '.porto-meta-tab' ).easyResponsiveTabs( { type: 'vertical' //, //default, vertical, accordion; } ); // taxonomy meta tab $( '.porto-tab-row' ).hide(); $( '.porto-tax-meta-tab' ).on( 'click', function( e ) { e.preventDefault(); var tab = $( this ).attr( 'data-tab' ); $( '.porto-tab-row[data-tab="' + tab + '"]' ).toggle(); return false; } ); // color field $( document ).on( 'plugin_init', '.porto-meta-color', function() { var $el = $( this ), $c = $el.find( '.porto-color-field' ), $t = $el.find( '.porto-color-transparency' ); $c.wpColorPicker( { change: function( e, ui ) { $( this ).val( ui.color.toString() ); $t.prop( 'checked', false ); }, clear: function( e, ui ) { $t.prop( 'checked', false ); } } ); $t.on( 'click', function() { if ( $( this ).is( ":checked" ) ) { $c.attr( 'data-old-color', $c.val() ); $c.val( 'transparent' ); $el.find( '.wp-color-result' ).css( 'background-color', 'transparent' ); } else { if ( $c.val() === 'transparent' ) { var oc = $c.attr( 'data-old-color' ); $el.find( '.wp-color-result' ).css( 'background-color', oc ); $c.val( oc ); } } } ); } ); $( '.porto-meta-color' ).each( function() { $( this ).trigger( 'plugin_init' ); } ); // meta required filter var filters = ['.postoptions .metabox', '.form-table .form-field']; $.each( filters, function( index, filter ) { $( filter + '[data-required]' ).each( function() { var $el = $( this ), id = $el.data( 'required' ), value = $el.data( 'value' ), $required = $( filter + ' [name="' + id + '"]' ), type = $required.attr( 'type' ); if ( $required.prop( 'type' ) == 'select-one' ) { $required.on( 'change', function() { if ( $.inArray( $required.val(), value.split( ',' ) ) !== -1 ) { $el.show(); } else { $el.hide(); } } ); $required.change(); } else { if ( type == 'checkbox' ) { $required.on( 'change', function() { if ( $( this ).is( ':checked' ) ) { if ( value ) { $el.show(); } else { $el.hide(); } } else { if ( !value ) { $el.show(); } else { $el.hide(); } } } ); $required.change(); } else if ( type == 'radio' ) { $required.on( 'click', function() { if ( $( this ).is( ':checked' ) ) { if ( $.inArray( $( this ).val(), value.split( ',' ) ) !== -1 ) { $el.show(); } else { $el.hide(); } } } ); $( filter + ' [name="' + id + '"]:checked' ).click(); } } } ); } ); // codemirror if ( typeof CodeMirror != 'undefined' ) { if ( document.getElementById( "custom_css" ) ) CodeMirror.fromTextArea( document.getElementById( "custom_css" ), { lineNumbers: true, mode: 'css' } ); if ( document.getElementById( "custom_js_head" ) ) CodeMirror.fromTextArea( document.getElementById( "custom_js_head" ), { lineNumbers: true, mode: 'javascript' } ); if ( document.getElementById( "custom_js_body" ) ) CodeMirror.fromTextArea( document.getElementById( "custom_js_body" ), { lineNumbers: true, mode: 'javascript' } ); } /** * @since 7.1.0 */ if ( ( typeof vc != 'undefined' && vc.atts && vc.atts.colorpicker ) || $.redux ) { $.a8c.iris.prototype._paletteListeners = function() { var self = this; self.picker.find('.iris-palette-container').on('click.palette', '.iris-palette', function() { self._color.fromCSS( $(this).data('color') ); self.active = 'external'; self.colorVariable = $(this).data('color'); self._change(); }).on( 'keydown.palette', '.iris-palette', function( event ) { if ( ! ( event.keyCode === 13 || event.keyCode === 32 ) ) { return true; } event.stopPropagation(); $( this ).trigger( 'click' ); }); } $.a8c.iris.prototype._change = function() { var self = this, controls = self.controls, color = self._getHSpaceColor(), actions = [ 'square', 'strip' ], controlOpts = self.options.controls, type = controlOpts[self.active] || 'external', oldHue = self.hue; if ( self.active === 'strip' ) { // take no action on any of the square sliders if we adjusted the strip actions = []; } else if ( self.active !== 'external' ) { // for non-strip, non-external, strip should never change actions.pop(); // conveniently the last item } $.each( actions, function(index, item) { var value, dimensions, cssObj; if ( item !== self.active ) { switch ( item ) { case 'strip': // reverse for hue if vertical value = ( controlOpts.strip === 'h' && ! self.horizontalSlider ) ? self._scale[ controlOpts.strip ] - color[ controlOpts.strip ] : color[controlOpts.strip]; controls.stripSlider.slider( 'value', value ); break; case 'square': dimensions = self._squareDimensions(); cssObj = { left: color[controlOpts.horiz] / self._scale[controlOpts.horiz] * dimensions.w, top: dimensions.h - ( color[controlOpts.vert] / self._scale[controlOpts.vert] * dimensions.h ) }; self.controls.squareDrag.css( cssObj ); break; } } }); // Ensure that we don't change hue if we triggered a hue reset if ( color.h !== oldHue && self._isNonHueControl( self.active, type ) ) { self._color.h(oldHue); } // store hue for repeating above check next time self.hue = self._color.h(); self.options.color = self._color.toString(); // only run after the first time if ( self._inited ) { self._trigger( 'change', { type: self.active }, { color: self.colorVariable && 0 == self.colorVariable.indexOf( 'var(--porto-' ) ? self.colorVariable : self._color } ); } if ( self.element.is( ':input' ) && ! self._color.error ) { self.element.removeClass( 'iris-error' ); if ( self.onlySlider ) { if ( self.element.val() !== self.hue ) { self.element.val( self.hue ); } } else { if ( self.element.val() !== self._color.toString() ) { self.element.val( self._color.toString() ); } } } if ( self.colorVariable && 0 == self.colorVariable.indexOf( 'var(--porto-' ) ) { self.element.removeClass( 'iris-error' ); if ( self.element.val() !== self.colorVariable ) { self.element.val( self.colorVariable ); } } self._paint(); self._inited = true; self.active = false; self.colorVariable = ''; } $.a8c.iris.prototype._addInputListeners = function( input ) { var self = this, debounceTimeout = 100, callback = function( event ){ var color = new Color( input.val() ), val = input.val().replace( /^#/, '' ); input.removeClass( 'iris-error' ); // we gave a bad color if ( color.error && input.val().indexOf( 'var(--porto-' ) == -1 ) { // don't error on an empty input - we want those allowed if ( val !== '' ) { input.addClass( 'iris-error' ); } } else { if ( color.toString() !== self._color.toString() ) { // let's not do this on keyup for hex shortcodes if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) ) { self._setOption( 'color', color.toString() ); } } } }; input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) ); // If we initialized hidden, show on first focus. The rest is up to you. if ( self.options.hide ) { input.one( 'focus', function() { self.show(); }); } } } /** * Init Yith Plugins * * @since 7.2.0 */ $( document ).on( 'widget-added', function ( e, $element ) { if ( $element.find( '.yith-colorpicker' ).length > 0 ) { setTimeout( () => { $element.find( '.yith-colorpicker' ).each( function () { $( this ).wpColorPicker(); } ) }, 1000 ); } }); } ); ( function() { 'use strict'; // Uploading files var file_frame, file_m_frame; var clickedID; jQuery( document ).off( 'click', '.button_upload_image' ).on( 'click', '.button_upload_image', function( event ) { event.preventDefault(); // If the media frame already exists, reopen it. if ( !file_frame ) { // Create the media frame. file_frame = wp.media.frames.downloadable_file = wp.media( { title: 'Choose an image', button: { text: 'Use image' }, multiple: false } ); } file_frame.open(); clickedID = jQuery( this ).data( 'id' ); // When an image is selected, run a callback. file_frame.on( 'select', function() { var attachment = file_frame.state().get( 'selection' ).first().toJSON(), $obj = jQuery( '#' + clickedID ); $obj.val( attachment.url ); if ( $obj.attr( 'data-name' ) ) $obj.attr( 'name', $obj.attr( 'data-name' ) ); file_frame.close(); } ); } ); jQuery( document ).off( 'click', '.button_attach_video' ).on( 'click', '.button_attach_video', function( event ) { event.preventDefault(); // If the media frame already exists, reopen it. if ( !file_frame ) { // Create the media frame. file_frame = wp.media.frames.downloadable_file = wp.media( { title: 'Choose an video', library: { type: 'video', query: false }, button: { text: 'Use video' }, multiple: false } ); } file_frame.open(); clickedID = jQuery( this ).data( 'id' ); // When an video is selected, run a callback. file_frame.on( 'select', function() { var attachment = file_frame.state().get( 'selection' ).first().toJSON(), $obj = jQuery( '#' + clickedID ); $obj.val( attachment.id ); jQuery( '#' + clickedID + '_thumb' ).html( '