I have used your code snippet at https://stachethemes.ticksy.com/article/13413/ edited as below, to ensure that all presentations of the calendar are as Agenda on Mobile phones. It seems the best choice for small screens.
On larger screens, I want to choose whether the calendar is presented as Grid or Agenda, but this code snippet now over-rides that choice. I have used the shortcodes:
Hi Zhivko
I have used your code snippet at https://stachethemes.ticksy.com/article/13413/
edited as below, to ensure that all presentations of the calendar are as Agenda on Mobile phones. It seems the best choice for small screens.
On larger screens, I want to choose whether the calendar is presented as Grid or Agenda, but this code snippet now over-rides that choice. I have used the shortcodes:
the first is to present as Grid, by default, and the second to present as Agenda.
But with this code snippet (below) they both present as Grid on larger screens.
I have tried commenting out the normalView line in the code, but then the calendar doesn't appear at all.
Is there a way to set mobileView to Agenda, as below, but leave the shortcode to determine the view on larger screens?
Thank you.
/* From: https://stachethemes.ticksy.com/article/13413/ * To change the mobile view just edit this line: var mobileView = 'grid'; * And for Desktop this one: var normalView = 'agenda'; */ add_action('wp_footer', function() { global $post; if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'stachethemes_ec')) { return; } ?> <script type="text/javascript"> (function ($) { $(function () { if (typeof $.stecExtend === 'undefined') { return; } // config vars var mobileView = 'agenda'; var normalView = 'grid'; $.stecExtend(function (m) { m.glob.options.view = m.helper.isMobile() ? mobileView : normalView; }); }); })(window.jQuery); </script> <?php });-->Hi,
Try following snippet:
add_action('wp_footer', function() {global $post;
if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'stachethemes_ec')) {
return;
}
?>
<script type="text/javascript">
(function ($) {
$(function () {
if (typeof $.stecExtend === 'undefined') {
return;
}
// config vars
var mobileView = 'agenda'; $.stecExtend(function (m) { if (m.helper.isMobile()) {
m.glob.options.view = mobileView;
}
});
});
})(window.jQuery);
</script>
<?php
});
This will change the view to agenda only for mobile.
Stachethemes Developer
Perfect!
Thank you.