Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery - view switcher example

0 votes
24 views
added Aug 24 in Javascript by LC Marshal Lieutenant (13,450 points)
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');
  })
})

 

Please log in or register to response this reference.

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