Skip to content

Instantly share code, notes, and snippets.

@2075
Created June 2, 2016 22:30
Show Gist options
  • Save 2075/2a5cc1d4bfa294a60957fef04150f2a6 to your computer and use it in GitHub Desktop.
Save 2075/2a5cc1d4bfa294a60957fef04150f2a6 to your computer and use it in GitHub Desktop.
code you find while debugging foreign code fragments
_isEventAllowed: function() {
// var allow = false,
var display = this.element.data('accordionDisplay');
if(display === undefined) {
return true;
}
// WTF, seriously?
// only if the last result is true we receive a true in return...
// if(display.match(/small/) ) {
// allow = Modernizr.mq("(max-width: 480px)");
// }
// if(display.match(/medium/) ) {
// allow = Modernizr.mq("(min-width: 481px) and (max-width: 767px)");
// }
// if(display.match(/large/) ) {
// allow = Modernizr.mq("(min-width: 768px) and (max-width: 991px)");
// }
// if(display.match(/extralarge/) ) {
// allow = Modernizr.mq("(min-width: 992px)");
// }
// this works better:
// if( display.match(/small/) &&
// Modernizr.mq("(max-width: 480px)") ) return true;
// if( display.match(/medium/) &&
// Modernizr.mq("(min-width: 481px) and (max-width: 767px)") ) return true;
// if( display.match(/large/) &&
// Modernizr.mq("(min-width: 768px) and (max-width: 991px)") ) return true;
// if(display.match(/extralarge/) &&
// Modernizr.mq("(min-width: 992px)") ) return true;
// better ;)
if( ( display.match(/small/) && Modernizr.mq("(max-width: 480px)") ) ||
( display.match(/medium/) && Modernizr.mq("(min-width: 481px) and (max-width: 767px)") ) ||
( display.match(/large/) && Modernizr.mq("(min-width: 768px) and (max-width: 991px)") ) ||
( display.match(/extralarge/) && Modernizr.mq("(min-width: 992px)") ) )
return true;
return false;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment