Skip to content

Instantly share code, notes, and snippets.

View diego-betto's full-sized avatar

Diego Betto diego-betto

View GitHub Profile
@diego-betto
diego-betto / bootstrap3-ios-modal-iframe-fix.css
Created April 10, 2017 09:43
Bootstrap 3 iOS modal iframe scrolling fix
.iframe-wrapper {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
function inlineSvg($file)
{
$theFile = get_template_directory().'/dist/images/'.$file.'.svg';
echo (is_file($theFile) ? file_get_contents(get_template_directory().'/dist/images/'.$file.'.svg') : '');
}
@diego-betto
diego-betto / url-hash-variables.js
Created February 17, 2017 11:46
js: url hash variables
function getHashVariable(variable) {
var query = window.location.hash.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
@diego-betto
diego-betto / dom-ready.js
Created November 14, 2016 16:37
DOM ready vanilla
<script>var domReady = function(callback) {document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);};</script>
addEventListener(document, "touchstart", function(e) {
console.log(e.defaultPrevented); // will be false
e.preventDefault(); // does nothing since the listener is passive
console.log(e.defaultPrevented); // still false
}, Modernizr.passiveeventlisteners ? {passive: true} : false);
@diego-betto
diego-betto / findBootstrapEnvironment.bootstrap.js
Last active April 10, 2017 09:49
JS: find current bootstrap 3 breakpoint
window.findBootstrapEnvironment = function() {
var envs = ['xs', 'sm', 'md', 'lg'];
var $el = jQuery('<div>');
$el.appendTo(jQuery('body'));
for (var i = envs.length - 1; i >= 0; i--) {
var env = envs[i];
$el.addClass('hidden-'+env);
swagger: '2.0'
info:
title: HostelsClub API
description: HostelsClub API
version: "1.0.0"
# the domain of the service
host: api.hostelsclub.com
# array of all schemes that your API supports
schemes:
- https
swagger: '2.0'
info:
title: HostelsClub API
description: HostelsClub API
version: "1.0.0"
# the domain of the service
host: api.hostelsclub.com
# array of all schemes that your API supports
schemes:
- https
@diego-betto
diego-betto / jquery-smooth-scroll.js
Last active April 10, 2017 09:50
smooth scroll js
jQuery(function() {
jQuery('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name="' + this.hash.slice(1) +'"]');
if (target.length) {
jQuery('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;