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

View File

@@ -0,0 +1,14 @@
(function ( $ ) {
'use strict';
$( document ).on( 'acf/setup_fields', function () {
// Redeclare active editor.
setTimeout( function () {
if ( 'tinymce' === getUserSetting( 'editor' ) ) {
$( '#content-tmce' ).trigger( 'click' );
} else {
$( '#content-html' ).trigger( 'click' );
}
}, 10 );
} );
})( window.jQuery );

View File

@@ -0,0 +1,62 @@
(function ( $ ) {
'use strict';
$( '#content-html' ).on( 'click', function () {
window.setTimeout( function () {
window.wpActiveEditor = 'qtrans_textarea_content';
}, 10 );
} );
$( window ).ready( function () {
var activeLang = qtrans_get_active_language(),
$langs = $( '#vc_vendor_qtranslate_langs' );
$( 'option', $langs ).each( function () {
var $el = $( this );
if ( $el.val() == activeLang ) {
$el.prop( 'selected', true );
}
$( '#qtrans_select_' + $el.val() ).on( 'click', function () {
$el.prop( 'selected', true );
} );
} );
$langs.on( 'change', function () {
$( '#qtrans_select_' + $( this ).val() ).trigger( 'click' );
var link = $( ":selected", this ).attr( 'link' );
$( '.wpb_switch-to-front-composer' ).each( function () {
$( this ).attr( 'href', link );
} );
$( '#wpb-edit-inline' ).attr( 'href', link );
vc.shortcodes.fetch( { reset: true } );
} );
$langs.show();
if ( !window.vc ) {
window.vc = {};
}
vc.QtransResetContent = function () {
$( '#content-html' ).trigger( 'click' );
$( '#qtrans_textarea_content' ).css( 'minHeight', '300px' );
window.wpActiveEditor = 'qtrans_textarea_content';
};
vc.Storage.prototype.getContent = function () {
var content;
vc.QtransResetContent();
content = $( '#qtrans_textarea_content' ).val();
if ( vc.gridItemEditor && !content.length ) {
content = vcDefaultGridItemContent;
}
return content;
};
vc.Storage.prototype.setContent = function ( content ) {
$( '#content-html' ).trigger( 'click' );
$( '#qtrans_textarea_content' ).val( content );
vc.QtransResetContent();
};
} );
})( window.jQuery );

View File

@@ -0,0 +1,30 @@
(function ( $ ) {
'use strict';
$( '#vc_vendor_qtranslate_langs_front' ).on( 'change', function () {
vc.closeActivePanel();
$( '#vc_logo' ).addClass( 'vc_ui-wp-spinner' );
window.location.href = $( this ).val();
} );
vc.ShortcodesBuilder.prototype.getContent = function () {
var output, $postContent, lang, content;
$postContent = $( '#vc_vendor_qtranslate_postcontent' );
lang = $postContent.attr( 'data-lang' );
content = $postContent.val();
vc.shortcodes.sort();
output = this.modelsToString( vc.shortcodes.where( { parent_id: false } ) );
return qtrans_integrate( lang, output, content );
};
vc.ShortcodesBuilder.prototype.getTitle = function () {
var $titleContent, lang, content;
$titleContent = $( '#vc_vendor_qtranslate_posttitle' );
lang = $titleContent.attr( 'data-lang' );
content = $titleContent.val();
return qtrans_integrate( lang, vc.title, content );
};
})( window.jQuery );

View File

@@ -0,0 +1,20 @@
(function ( $ ) {
'use strict';
function hookLanguageSwitch( activeLang ) {
var $inline_href = $( '.wpb_switch-to-front-composer' );
if ( !$inline_href.data( 'raw-url' ) ) {
$inline_href.data( 'raw-url', $inline_href.attr( 'href' ) );
}
var new_url = $inline_href.data( 'raw-url' ) + '&lang=' + activeLang;
$inline_href.attr( 'href', new_url );
vc.shortcodes.fetch( { reset: true } );
}
$( function () {
var qtranslateManager = qTranslateConfig.js.get_qtx();
qtranslateManager.addLanguageSwitchListener( hookLanguageSwitch );
} );
})( window.jQuery );

View File

@@ -0,0 +1,18 @@
(function ( $ ) {
'use strict';
$( '#vc_vendor_qtranslatex_langs_front' ).on( 'change', function () {
vc.closeActivePanel();
$( '#vc_logo' ).addClass( 'vc_ui-wp-spinner' );
window.location.href = $( this ).val();
} );
var native_getContent = vc.ShortcodesBuilder.prototype.getContent;
vc.ShortcodesBuilder.prototype.getContent = function () {
var content = native_getContent();
$( '#content' ).val( content );
return content;
};
})( window.jQuery );

View File

@@ -0,0 +1,26 @@
(function ( $ ) {
'use strict';
$( document ).ready( function () {
$( 'body' ).on( 'adding_to_cart', function ( event, $button, data ) {
if ( $button && $button.hasClass( 'vc_gitem-link' ) ) {
$button
.addClass( 'vc-gitem-add-to-cart-loading-btn' )
.parents( '.vc_grid-item-mini' )
.addClass( 'vc-woocommerce-add-to-cart-loading' )
.append( $( '<div class="vc_wc-load-add-to-loader-wrapper"><div class="vc_wc-load-add-to-loader"></div></div>' ) );
}
} ).on( 'added_to_cart', function ( event, fragments, cart_hash, $button ) {
if ( 'undefined' === typeof ($button) ) {
$button = $( '.vc-gitem-add-to-cart-loading-btn' );
}
if ( $button && $button.hasClass( 'vc_gitem-link' ) ) {
$button
.removeClass( 'vc-gitem-add-to-cart-loading-btn' )
.parents( '.vc_grid-item-mini' )
.removeClass( 'vc-woocommerce-add-to-cart-loading' )
.find( '.vc_wc-load-add-to-loader-wrapper' ).remove();
}
} );
} );
})( window.jQuery );

View File

@@ -0,0 +1,45 @@
if ( !window.ajaxurl ) {
window.ajaxurl = window.location.href;
}
(function ( $ ) {
'use strict';
var vcWoocommerceProductAttributeFilterDependencyCallback;
vcWoocommerceProductAttributeFilterDependencyCallback = function () {
(function ( $, that ) {
var $filterDropdown, $empty;
$filterDropdown = $( '[data-vc-shortcode-param-name="filter"]', that.$content );
$filterDropdown.removeClass( 'vc_dependent-hidden' );
$empty = $( '#filter-empty', $filterDropdown );
if ( $empty.length ) {
$empty.parent().remove();
$( '.edit_form_line', $filterDropdown ).prepend( $( '<div class="vc_checkbox-label"><span>No values found</span></div>' ) );
}
$( 'select[name="attribute"]', that.$content ).on( 'change', function () {
$( '.vc_checkbox-label', $filterDropdown ).remove();
$filterDropdown.removeClass( 'vc_dependent-hidden' );
$.ajax( {
type: 'POST',
dataType: 'json',
url: window.ajaxurl,
data: {
action: 'vc_woocommerce_get_attribute_terms',
attribute: this.value,
_vcnonce: window.vcAdminNonce
}
} ).done( function ( data ) {
if ( 0 < data.length ) {
$( '.edit_form_line', $filterDropdown ).prepend( $( data ) );
} else {
$( '.edit_form_line', $filterDropdown ).prepend( $( '<div class="vc_checkbox-label"><span>No values found</span></div>' ) );
}
} );
} );
}( window.jQuery, this ));
};
window.vcWoocommerceProductAttributeFilterDependencyCallback = vcWoocommerceProductAttributeFilterDependencyCallback;
})( window.jQuery );

View File

@@ -0,0 +1,93 @@
/* global vc, YoastSEO, _, jQuery */
(function ( $ ) {
'use strict';
$( window ).on( 'YoastSEO:ready', function () {
var imageEventString, vcYoast, relevantData, pluginName, eventsList;
relevantData = {};
pluginName = 'vcVendorYoast';
eventsList = [
'sync',
'add',
'update'
];
var contentModification = function ( data ) {
data = _.reduce( relevantData, function ( memo, value, key ) {
if ( value.html ) {
memo = memo.replace( '"' + value.text + '"', value.html );
}
if ( value.image && value.param ) {
var i, imagesString = '', attachment;
for ( i = 0; value.image.length > i; i ++ ) {
attachment = window.wp.media.model.Attachment.get( value.image[ i ] );
if ( attachment.get( 'url' ) ) {
imagesString += '<img src=\'' + attachment.get( 'url' ) + '\' alt=\'' + (attachment.get( 'alt' ) || attachment.get( 'caption' ) || attachment.get( 'title' )) + '\'>';
}
}
memo += imagesString;
}
return memo;
}, data );
return data;
};
function getImageEventString( e ) {
return ' shortcodes:' + e + ':param:type:attach_image' + ' shortcodes:' + e + ':param:type:attach_images';
}
// add relevant data for images
imageEventString = _.reduce( eventsList, function ( memo, e ) {
return memo + getImageEventString( e );
}, '' );
vc.events.on( imageEventString, function ( model, param, settings ) {
if ( param && param.length > 0 ) {
var ids = param.split( /\s*,\s*/ );
_.each( ids, function ( id ) {
var attachment = window.wp.media.model.Attachment.get( id );
if ( !attachment.get( 'url' ) ) {
attachment.once( 'sync', function () {
YoastSEO.app.pluginReloaded( pluginName );
} );
attachment.fetch();
}
} );
relevantData[ model.get( 'id' ) + settings.param_name ] = {
image: ids,
paramName: settings.param_name,
param: param
};
}
} );
vc.events.on( getImageEventString( 'destroy' ), function ( model, param, settings ) {
delete relevantData[ model.get( 'id' ) + settings.param_name ];
} );
// Add relevant data to headings
vc.events.on( 'shortcodes:vc_custom_heading', function ( model, event ) {
var params, tagSearch;
params = model.get( 'params' );
params = _.extend( {}, vc.getDefaults( model.get( 'shortcode' ) ), params );
if ( 'destroy' === event ) {
delete relevantData[ model.get( 'id' ) ];
} else if ( params.text && params.font_container ) {
tagSearch = params.font_container.match( /tag:([^\|]+)/ );
if ( tagSearch[ 1 ] ) {
relevantData[ model.get( 'id' ) ] = {
html: '<' + tagSearch[ 1 ] + '>' + params.text + '</' + tagSearch[ 1 ] + '>',
text: params.text
};
}
}
} );
var VcVendorYoast = function () {
// init
YoastSEO.app.registerPlugin( pluginName, { status: 'ready' } );
YoastSEO.app.pluginReady( pluginName );
YoastSEO.app.registerModification( 'content', contentModification, pluginName, 5 );
};
vcYoast = new VcVendorYoast();
} );
})( window.jQuery );