60 lines
2.8 KiB
JavaScript
60 lines
2.8 KiB
JavaScript
|
/*! jRespond.js v 0.10 | Author: Jeremy Fields [jeremy.fields@viget.com], 2013 | License: MIT */
|
||
|
!function(a,b,c){"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=c:(a[b]=c,"function"==typeof define&&define.amd&&define(b,[],function(){return c}))}(this,"jRespond",function(a,b,c){"use strict";return function(a){var b=[],d=[],e=a,f="",g="",i=0,j=100,k=500,l=k,m=function(){var a=0;return a="number"!=typeof window.innerWidth?0!==document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth:window.innerWidth},n=function(a){if(a.length===c)o(a);else for(var b=0;b<a.length;b++)o(a[b])},o=function(a){var e=a.breakpoint,h=a.enter||c;b.push(a),d.push(!1),r(e)&&(h!==c&&h.call(null,{entering:f,exiting:g}),d[b.length-1]=!0)},p=function(){for(var a=[],e=[],h=0;h<b.length;h++){var i=b[h].breakpoint,j=b[h].enter||c,k=b[h].exit||c;"*"===i?(j!==c&&a.push(j),k!==c&&e.push(k)):r(i)?(j===c||d[h]||a.push(j),d[h]=!0):(k!==c&&d[h]&&e.push(k),d[h]=!1)}for(var l={entering:f,exiting:g},m=0;m<e.length;m++)e[m].call(null,l);for(var n=0;n<a.length;n++)a[n].call(null,l)},q=function(a){for(var b=!1,c=0;c<e.length;c++)if(a>=e[c].enter&&a<=e[c].exit){b=!0;break}b&&f!==e[c].label?(g=f,f=e[c].label,p()):b||""===f||(f="",p())},r=function(a){if("object"==typeof a){if(a.join().indexOf(f)>=0)return!0}else{if("*"===a)return!0;if("string"==typeof a&&f===a)return!0}},s=function(){var a=m();a!==i?(l=j,q(a)):l=k,i=a,setTimeout(s,l)};return s(),{addFunc:function(a){n(a)},getBreakpoint:function(){return f}}}}(this,this.document));
|
||
|
|
||
|
SEMICOLON.widget.respondInit = function( $respondEl ){
|
||
|
|
||
|
$respondEl = $respondEl.filter(':not(.customjs)');
|
||
|
|
||
|
if( $respondEl.length < 1 ){
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
let jRes = jRespond([
|
||
|
{
|
||
|
label: 'smallest',
|
||
|
enter: 0,
|
||
|
exit: 575
|
||
|
},{
|
||
|
label: 'handheld',
|
||
|
enter: 576,
|
||
|
exit: 767
|
||
|
},{
|
||
|
label: 'tablet',
|
||
|
enter: 768,
|
||
|
exit: 991
|
||
|
},{
|
||
|
label: 'laptop',
|
||
|
enter: 992,
|
||
|
exit: 1199
|
||
|
},{
|
||
|
label: 'desktop',
|
||
|
enter: 1200,
|
||
|
exit: 10000
|
||
|
}
|
||
|
]);
|
||
|
jRes.addFunc([
|
||
|
{
|
||
|
breakpoint: 'desktop',
|
||
|
enter: function() { $respondEl.addClass('device-xl'); },
|
||
|
exit: function() { $respondEl.removeClass('device-xl'); }
|
||
|
},{
|
||
|
breakpoint: 'laptop',
|
||
|
enter: function() { $respondEl.addClass('device-lg'); },
|
||
|
exit: function() { $respondEl.removeClass('device-lg'); }
|
||
|
},{
|
||
|
breakpoint: 'tablet',
|
||
|
enter: function() { $respondEl.addClass('device-md'); },
|
||
|
exit: function() { $respondEl.removeClass('device-md'); }
|
||
|
},{
|
||
|
breakpoint: 'handheld',
|
||
|
enter: function() { $respondEl.addClass('device-sm'); },
|
||
|
exit: function() { $respondEl.removeClass('device-sm'); }
|
||
|
},{
|
||
|
breakpoint: 'smallest',
|
||
|
enter: function() { $respondEl.addClass('device-xs'); },
|
||
|
exit: function() { $respondEl.removeClass('device-xs'); }
|
||
|
}
|
||
|
]);
|
||
|
|
||
|
};
|