Skip to content

Instantly share code, notes, and snippets.

@yratof
Created December 20, 2013 15:48
Show Gist options
  • Save yratof/8056627 to your computer and use it in GitHub Desktop.
Save yratof/8056627 to your computer and use it in GitHub Desktop.
RoyalJs
// IE8 ployfill for GetComputed Style (for Responsive Script below)
if (!window.getComputedStyle) {
window.getComputedStyle = function(el) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop === 'float') {prop = 'styleFloat';}
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
};
return this;
};
}
var Modernizr;
var min_width;
if (Modernizr.mq('(min-width: 0px)')) {
// Browsers that support media queries
min_width = function (width) {
return Modernizr.mq('(max-width: ' + width + 'px)');
};
}
else {
// Fallback for browsers that does not support media queries
min_width = function (width) {
return jQuery(window).width() >= width;
};
}
// as the page loads, call these scripts
jQuery(document).ready(function($) {
/*
Responsive jQuery is a tricky thing.
There's a bunch of different ways to handle
it, so be sure to research and find the one
that works for you best.
*/
/* getting viewport width */
var resize = function() {
/* if is below 481px */
if (min_width(481)) {
$('.new-royalslider-1').royalSlider({
template:'default',
image_generation:{
imageWidth:880,
imageHeight:440,
thumbImageWidth:'',
thumbImageHeight:''
},
thumbs:{
thumbWidth:96,
thumbHeight:72
},
autoPlay:{
enabled:!0,
delay:5000
},
visibleNearby:{
enabled:!0,
hiddenOverflow:!1,
centerArea:0.5,
breakpoint:680,
breakpointCenterArea:0.75,
navigateByCenterClick:!0
},
video:{
autoHideBlocks:!0
},
block:{
moveOffset:20,
speed:400,
delay:200
},
width:'100%',
height:'430px',
autoScaleSlider:!0,
autoScaleSliderWidth:1440,
autoScaleSliderHeight:430,
slidesSpacing:10,
imageScaleMode:'fill',
imageAlignCenter:!1,
imageScalePadding:0,
controlNavigation:'none',
arrowsNav:!1,
arrowsNavAutoHide:!1,
arrowsNavHideOnTouch:!0,
transitionSpeed:1200,
loop:!0,
keyboardNavEnabled:!0,
fadeinLoadedSlide:!1,
addActiveClass:!0
});
} /* end smallest screen */
/* if is larger than 481px */
if (min_width(481)) {
$('.new-royalslider-1').royalSlider({
template:'default',
image_generation:{
imageWidth:880,
imageHeight:440,
thumbImageWidth:'',
thumbImageHeight:''
},
thumbs:{
thumbWidth:96,
thumbHeight:72
},
autoPlay:{
enabled:!0,
delay:5000
},
visibleNearby:{
enabled:!0,
hiddenOverflow:!1,
centerArea:0.5,
breakpoint:680,
breakpointCenterArea:0.75,
navigateByCenterClick:!0
},
video:{
autoHideBlocks:!0
},
block:{
moveOffset:20,
speed:400,
delay:200
},
width:'100%',
height:'430px',
autoScaleSlider:!0,
autoScaleSliderWidth:1440,
autoScaleSliderHeight:430,
slidesSpacing:10,
imageScaleMode:'fill',
imageAlignCenter:!1,
imageScalePadding:0,
controlNavigation:'none',
arrowsNav:!1,
arrowsNavAutoHide:!1,
arrowsNavHideOnTouch:!0,
transitionSpeed:1200,
loop:!0,
keyboardNavEnabled:!0,
fadeinLoadedSlide:!1,
addActiveClass:!0
});
} /* end larger than 481px */
/* if is above or equal to 768px */
if (min_width(768)) {
$('.new-royalslider-1').royalSlider({
template:'default',
image_generation:{
imageWidth:880,
imageHeight:440,
thumbImageWidth:'',
thumbImageHeight:''
},
thumbs:{
thumbWidth:96,
thumbHeight:72
},
autoPlay:{
enabled:!0,
delay:5000
},
visibleNearby:{
enabled:!0,
hiddenOverflow:!1,
centerArea:0.5,
breakpoint:680,
breakpointCenterArea:0.75,
navigateByCenterClick:!0
},
video:{
autoHideBlocks:!0
},
block:{
moveOffset:20,
speed:400,
delay:200
},
width:'100%',
height:'430px',
autoScaleSlider:!0,
autoScaleSliderWidth:1440,
autoScaleSliderHeight:430,
slidesSpacing:10,
imageScaleMode:'fill',
imageAlignCenter:!1,
imageScalePadding:0,
controlNavigation:'none',
arrowsNav:!1,
arrowsNavAutoHide:!1,
arrowsNavHideOnTouch:!0,
transitionSpeed:1200,
loop:!0,
keyboardNavEnabled:!0,
fadeinLoadedSlide:!1,
addActiveClass:!0
});
}
/* off the bat large screen actions */
if (min_width(1030)) {
}
};
$(window).resize(resize);
resize();
}); /* end of as page load scripts */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment