treehouse : what would you like to learn today?
Web Design Web Development iOS Development

DRY Coding with enqire.js and elastislide

  • I'm using elastislide in a new responsive project - along with enquire.js and feel like there is a better, cleaner and DRY (don't repeat yourself) solution for it.

    enquire
        .register('screen and (max-width: 699px)', function() {
          // carousel settings
          $('#carousel').elastislide({
            imageW    : 286,
            minItems  : 2,
            border    : 7,
            margin    : 20,
            onClick   : function() {
              window.open($item.index);
            }
          });
        })
        .register('screen and (min-width: 700px)', function() {
          // carousel settings
          $('#carousel').elastislide({
            imageW    : 286,
            minItems  : 3,
            border    : 7,
            margin    : 30,
            onClick   : function() {
              window.open($item.index);
            }
          });
        })
        .listen();
    

    Is there a way to set all plugin settings by default and then only the ones I want changed for the different sizes to cut down on the number of repeats? Any help would be greatly appreciated