js localization

This commit is contained in:
Leo Germani 2018-10-01 13:52:38 -03:00
parent d5cbe43b96
commit a31c1ae090
6 changed files with 27 additions and 11 deletions

View File

@ -95,4 +95,6 @@ jQuery( document ).ready(function( $ ) {
]
});
$('.tainacan-interface-truncate').tainacan_interface_truncate();
});

View File

@ -4,8 +4,8 @@
showChars: 350,
minChars: 100,
ellipsesText: "...",
moreText: "More",
lessText: "Less"
moreText: tainacan_trucanteVars.moreText,
lessText: tainacan_trucanteVars.lessText
};
if (settings) {
@ -19,8 +19,8 @@
if(t.length < config.minChars) return;
$(this).html(
t.slice(0,config.showChars)+'<span>'+ config.ellipsesText +' </span><a href="#" class="tainacan-interface-more">'+ config.moreText +'</a>'+
'<span style="display:none;">'+ t.slice(config.showChars,t.length)+' <a href="#" class="tainacan-interface-less">'+ config.lessText +'</a></span>'
t.slice(0,config.showChars)+'<span>'+ config.ellipsesText +' </span><a href="#" class="tainacan-interface-more">[ '+ config.moreText +' ]</a>'+
'<span style="display:none;">'+ t.slice(config.showChars,t.length)+' <a href="#" class="tainacan-interface-less">[ '+ config.lessText +' ]</a></span>'
);
});

View File

@ -17,6 +17,15 @@ class TainacanThemeCollectionColor {
function action_tainacan_enqueue_admin_scripts() {
wp_enqueue_script( 'colorWell', get_template_directory_uri() . '/functions/collection-color.js', false, false, true );
wp_enqueue_style( 'colorWellStyle', get_template_directory_uri() . '/functions/collection-color.css' );
wp_localize_script( 'colorWell', 'tainacan_colorPickerVars', [
'cancelText' => __("cancel", 'tainacan-interface'),
'chooseText' => __("choose", 'tainacan-interface'),
'togglePaletteMoreText' => __("more", 'tainacan-interface'),
'togglePaletteLessText' => __("less", 'tainacan-interface'),
'clearText' => __("Clear Color Selection", 'tainacan-interface'),
'noColorSelectedText' => __("No Color Selected", 'tainacan-interface'),
] );
wp_enqueue_script( 'Spectrum', get_template_directory_uri() . '/assets/js/spectrum.js', false, false, true );
wp_enqueue_style( 'Spectrum', get_template_directory_uri() . '/assets/js/spectrum.css' );
}

View File

@ -1,6 +1,12 @@
jQuery( document ).on( 'tainacan-collection-hook-reload', function() {
jQuery( "#colorpicker" ).spectrum({
showPalette: true,
cancelText: tainacan_colorPickerVars.cancelText,
chooseText: tainacan_colorPickerVars.chooseText,
togglePaletteMoreText: tainacan_colorPickerVars.togglePaletteMoreText,
togglePaletteLessText: tainacan_colorPickerVars.togglePaletteLessText,
clearText: tainacan_colorPickerVars.clearText,
noColorSelectedText: tainacan_colorPickerVars.noColorSelectedText,
palette: [
['#298596', '#a55032', '#af2e48', '#c58738', '#4ebfa7'],
['#288698', '#2db4c1', '#499dd6', '#4751a3', '#955ba5'],

View File

@ -47,6 +47,11 @@ if ( ! function_exists( 'tainacan_enqueues' ) ) {
*/
wp_enqueue_script( 'tainacanTruncate', get_template_directory_uri() . '/assets/js/tainacan-interface-truncate.js', array( 'jquery' ), '1.0', false );
wp_register_style( 'tainacanStyle', get_stylesheet_uri(), array( 'bootstrap4CSS' ) );
wp_localize_script( 'tainacanTruncate', 'tainacan_trucanteVars', [
"moreText" => __('More', 'tainacan-interface'),
"lessText" => __('Less', 'tainacan-interface')
]);
wp_enqueue_style( 'tainacanStyle' );
wp_register_script( 'tainacanJS', get_template_directory_uri() . '/assets/js/js.js', '', '1.0', true );
wp_enqueue_script( 'tainacanJS' );

View File

@ -103,9 +103,3 @@ echo '</style>';
</div>
</div>
</div>
<script>
jQuery('.tainacan-interface-truncate').tainacan_interface_truncate({
"moreText": "<?php _e('More', 'tainacan-interface'); ?>",
"lessText": "<?php _e('Less', 'tainacan-interface'); ?>"
});
</script>