Blender-org web-assets v2 upgrade #104116

Merged
Márton Lente merged 56 commits from web-assets-v2-upgrade into main 2024-08-13 17:27:59 +02:00
2 changed files with 32 additions and 27 deletions
Showing only changes of commit 79b158d861 - Show all commits

View File

@ -102,24 +102,26 @@ $style = get_field('style');
<?php endif; ?>
</div>
<?
<?php
if (!function_exists('js_footer')) {
wp_enqueue_script('hammer', get_template_directory_uri() . '/assets/js/hammer-2.0.8.min.js');
function js_footer() {
// The images-compare script was modified to work with jQuery 3 (basically replacing .load and .error with .on('load', ...))
wp_enqueue_script('hammer', get_template_directory_uri() . '/assets/js/hammer-2.0.8.min.js');
wp_enqueue_script('media-compare', get_template_directory_uri() . '/assets/js/jquery.images-compare-0.2.5.js');
// The images-compare script was modified to work with jQuery 3 (basically replacing .load and .error with .on('load', ...))
wp_enqueue_script('media-compare', get_template_directory_uri() . '/assets/js/jquery.images-compare-0.2.5.js');
// Execute JavaScript inline after 'media-compare'
$inline_script = <<<EOD
(function($) {
$(document).ready(function() {
$('.images-compare').imagesCompare();
});
})(jQuery);
EOD;
wp_add_inline_script('media-compare', $inline_script);
}
function js_footer();
?>
<script type='text/javascript'>
$(document).ready(function() {
$('.images-compare').imagesCompare();
});
</script>
<?php
add_action('wp_footer', 'js_footer');
}
?>
<?php endif; ?>
endif;

View File

@ -477,21 +477,24 @@ $is_latest = (($version_number >= $current_version_number) ? true : false);
<?php endwhile; // end of the loop. ?>
<?php
// TODO: cleanup function definition and call 'js_footer' if is not needed
Review

I don't see how this relates to v2? I don't think we change any JavaScript other than renaming some classes.

I don't see how this relates to v2? I don't think we change any JavaScript other than renaming some classes.
Review

There were some PHP fatal errors happening on the local dev server, likely because of the less permissive PHP error handling, and minor PHP config differences on localhost. (It's just a coincidence that it relates to JavaScript, as the rendered markup broke while calling / working with JS functions.) These changes are related to resolving these issues, which likely exist in production without causing problems. Added todos are for possible JS refactors I noticed while working on the latter.

See #79b158d

There were some PHP fatal errors happening on the local dev server, likely because of the less permissive PHP error handling, and minor PHP config differences on localhost. (It's just a coincidence that it relates to JavaScript, as the rendered markup broke while calling / working with JS functions.) These changes are related to resolving these issues, which likely exist in production without causing problems. Added todos are for possible JS refactors I noticed while working on the latter. See [#79b158d](https://projects.blender.org/infrastructure/blender-org/commit/79b158d8615ff46f08314b5b141bad52d6da7b08)
function js_footer() {
// The images-compare script was modified to work with jQuery 3 (basically replacing .load and .error with .on('load', ...))
wp_enqueue_script('hammer', get_template_directory_uri() . '/assets/js/hammer-2.0.8.min.js');
wp_enqueue_script('media-compare', get_template_directory_uri() . '/assets/js/jquery.images-compare-0.2.5.js');
wp_enqueue_script('hammer', get_template_directory_uri() . '/assets/js/hammer-2.0.8.min.js');
// Execute JavaScript inline after 'media-compare'
$inline_script = <<<EOD
(function($) {
$(document).ready(function() {
$('.images-compare').imagesCompare();
});
})(jQuery);
EOD;
// The media-compare script was modified to work with jQuery 3 (basically replacing .load and .error with .on('load', ...))
wp_enqueue_script('media-compare', get_template_directory_uri() . '/assets/js/jquery.images-compare-0.2.5.js');
wp_add_inline_script('media-compare', $inline_script);
}
function js_footer(){
?>
<script type='text/javascript'>
$(document).ready(function() {
$('.images-compare').imagesCompare();
});
</script>
<?php }
add_action('wp_footer', 'js_footer');
?>