title: Script JQuery Gallery, pass the CSS class as parameter of a function
body: <p>Hi I'm new in javascript/programming and I cannot find a reasonable solution for a script who is in charge of giving parameters to each photo gallery. The script is working fine, but as I wrote, I think it can be simplified to no repetition of parameters. There is just one parameter (the class selector) that is changing from each gallery script.</p>
  
  <pre><code>$(document).ready(function() {
        $('.popup-gallery-wakipo').magnificPopup({ // HERE THE CLASS SELECTOR
          delegate: 'a.gallery_portf',
          type: 'image',
          tLoading: 'Loading image #%curr%...',
          mainClass: 'mfp-img-mobile',
          gallery: {
            enabled: true,
            navigateByImgClick: true,
            preload: [0,1]
          },
          image: {
            tError: '',
            titleSrc: function(item) {
              return item.el.attr('title') + '';
              }
          }
        });
  
  
        $('.popup-gallery-instacash').magnificPopup({ // HERE THE CLASS SELECTOR
          delegate: 'a.gallery_portf',
          type: 'image',
          tLoading: 'Loading image #%curr%...',
          mainClass: 'mfp-img-mobile',
          gallery: {
            enabled: true,
            navigateByImgClick: true,
            preload: [0,1]
          },
          image: {
            tError: '',
            titleSrc: function(item) {
              return item.el.attr('title') + '';
            }
          }
        });
  </code></pre>
  
  <p>etc...</p>
  
  <p>So the question is how to modularize this script for just pass that class selector as parameter. Maybe with an Object Construtor/Method, I've tried but I get lost make it work</p>
  
  <pre><code>  function Gallery (theclass){
  
      $('.' + theclass).magnificPopup({
        delegate: 'a.gallery_portf',
        type: 'image',
        tLoading: 'Loading image #%curr%...',
        mainClass: 'mfp-img-mobile',
        gallery: {
          enabled: true,
          navigateByImgClick: true,
          preload: [0,1]
        },
        image: {
          tError: '',
          titleSrc: function(item) {
            return item.el.attr('title') + '';
  
          }
        }
      });
  
    }
  
    var mySecondGallery = new Gallery("popup-gallery-wakipo");
  
    mySecondGallery ();
  </code></pre>