/*! * Responsive Bootstrap Toolkit * Author: Maciej Gurban * License: MIT * Version: 2.6.3 (2016-06-21) * Origin: https://github.com/maciej-gurban/responsive-bootstrap-toolkit */ var ResponsiveBootstrapToolkit = (function($){ // Internal methods var internal = { /** * Breakpoint detection divs for each framework version */ detectionDivs: { // Bootstrap 3 bootstrap: { 'xs': $('
'), 'sm': $(''), 'md': $(''), 'lg': $('') }, // Foundation 5 foundation: { 'small': $(''), 'medium': $(''), 'large': $(''), 'xlarge': $('') } }, /** * Append visibility divs after DOM laoded */ applyDetectionDivs: function() { $(document).ready(function(){ $.each(self.breakpoints, function(alias){ self.breakpoints[alias].appendTo('.responsive-bootstrap-toolkit'); }); }); }, /** * Determines whether passed string is a parsable expression */ isAnExpression: function( str ) { return (str.charAt(0) == '<' || str.charAt(0) == '>'); }, /** * Splits the expression in into <|> [=] alias */ splitExpression: function( str ) { // Used operator var operator = str.charAt(0); // Include breakpoint equal to alias? var orEqual = (str.charAt(1) == '=') ? true : false; /** * Index at which breakpoint name starts. * * For: >sm, index = 1 * For: >=sm, index = 2 */ var index = 1 + (orEqual ? 1 : 0); /** * The remaining part of the expression, after the operator, will be treated as the * breakpoint name to compare with */ var breakpointName = str.slice(index); return { operator: operator, orEqual: orEqual, breakpointName: breakpointName }; }, /** * Returns true if currently active breakpoint matches the expression */ isAnyActive: function( breakpoints ) { var found = false; $.each(breakpoints, function( index, alias ) { // Once first breakpoint matches, return true and break out of the loop if( self.breakpoints[ alias ].is(':visible') ) { found = true; return false; } }); return found; }, /** * Determines whether current breakpoint matches the expression given */ isMatchingExpression: function( str ) { var expression = internal.splitExpression( str ); // Get names of all breakpoints var breakpointList = Object.keys(self.breakpoints); // Get index of sought breakpoint in the list var pos = breakpointList.indexOf( expression.breakpointName ); // Breakpoint found if( pos !== -1 ) { var start = 0; var end = 0; /** * Parsing viewport.is('<=md') we interate from smallest breakpoint ('xs') and end * at 'md' breakpoint, indicated in the expression, * That makes: start = 0, end = 2 (index of 'md' breakpoint) * * Parsing viewport.is('