Skip to content

Commit

Permalink
Adds responsive plugins, updates dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMJones committed Mar 15, 2018
1 parent a40a52e commit 8e32d98
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 34 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"sass",
"scss",
"strapless",
"css"
"rwd"
],
"homepage": "https://www.github.com/strapless/responsive",
"version": "1.0",
"version": "1.0.1",
"authors": [
{
"name": "Aaron M Jones",
Expand All @@ -18,7 +18,7 @@
],
"license": "MIT",
"require": {
"strapless/base": "^1.1",
"strapless/base": "^2.0",
"exactquery/xq-detect": "^2.2"
}
}
33 changes: 33 additions & 0 deletions js/afterwards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Fires an event after the last repeated event. Useful for resize & similar events.
*
* @returns {jQuery}
*/
;(function($){
$.fn.extend({
afterwards: function( eventName, callback, options ) {

var plugin = this;
var $plugin = $(plugin);
var eTimer;

plugin.defaultOptions = {
'interval': 250,
'preventDefault': false,
'stopPropagation': false
};

var settings = $.extend({}, plugin.defaultOptions, options);

return $plugin.on(eventName, function(e) {

if ( settings.preventDefault ) { e.preventDefault(); }
if ( settings.stopPropagation ) { e.stopPropagation(); }
if ( settings.stopImmediatePropagation ) { e.stopImmediatePropagation(); }

clearTimeout(eTimer);
eTimer = setTimeout(callback, settings.interval);
});
}
});
})(jQuery);
28 changes: 28 additions & 0 deletions js/breakpoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Determines which breakpoint is currently active, either by querying for a psuedo element on the body
* or by injecting an element with display classes.
*
* @returns {jQuery}
*/
jQuery.fn.extend( {
isBreakpoint: function ( points ) {
var query = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content').replace(/\"/g, '') || null;
if ( !points.constructor === Array ) { points = [ points ]; }
if (null !== query) { return (points.indexOf(query) !== -1); }
var test = false;
var $body = $( 'body' );
var cls = ' d-none d-sm-none d-md-none d-lg-none d-xl-none';
$.each( points, function ( index, alias ) {
if ( !$body.find( '.detect-' + alias ).length ) {
var tCls = 'detect-' + alias + cls;
tCls = (alias === 'xs') ? tCls.replace('d-none','d-inline') : tCls.replace(alias + '-none',alias + '-inline');
$body.append( '<span class="' + tCls + '"></span>' );
}
if ( $( '.detect-' + alias ).first().is( ':visible' ) ) {
test = true;
return false;
}
} );
return test
}
} );
32 changes: 1 addition & 31 deletions scss/_rwd-functions.scss
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
@import "rwd-variables";
@import "strapless/base/scss/functions/map";
@import "strapless/base/scss/base";

// region //////////////////////////////////////////////// String Functions

// Explodes a string into a SASS list by the given delimiter
// @author Hugo Giraudel (modified from original)
@function _str-explode($string, $delimiter: "") {
$result: ();
$length: str-length($string);

@if str-length($delimiter) == 0 {
@for $i from 1 through $length {
$result: append($result, str-slice($string, $i, $i));
}

@return $result;
}

$running: true;
$remaining: $string;

@while $running {
$index: str-index($remaining, $delimiter);

@if $index {
$slice: str-slice($remaining, 1, $index - 1);
$result: append($result, $slice);
$remaining: str-slice($remaining, $index + str-length($delimiter));
} @else {
$running: false;
}
}

@return append($result, $remaining);
}

// endregion ///////////////////////////////////////////// End String Functions

Expand Down

0 comments on commit 8e32d98

Please sign in to comment.