jQuery - view switcher example

0 votes
232 views
added Aug 24, 2018 in jQuery by LC Marshal Captain (25,790 points)
recategorized Oct 17, 2018 by LC Marshal
jQuery(document).ready(function () {
  jQuery('#map-view').hide();
  if (<?php print count($projects);?>) {
    selectProject(0);
  }
  jQuery('.view-switcher .pill').click(function (e) {
    e.preventDefault();
    var view = jQuery(this).attr('data');
    if (view == 'grid-view') {
      jQuery('#map-view').css('display','none');
      jQuery('#grid-view').show();
    } else {
      jQuery('#grid-view').hide();
      if (jQuery(window).width() < 768) {
         jQuery('#map-view').css('display','block');
         jQuery('.m-map #map').addClass('map-on-m');
         jQuery('.m-map .projects').addClass('list-on-m');
      }
      else {
         jQuery('#map-view').css('display','flex');
      }   
    }
    jQuery('.view-switcher .pill').removeClass('active');
    jQuery(this).addClass('active');
  })
})

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...