Skip to content

Instantly share code, notes, and snippets.

View miguel-perez's full-sized avatar

Miguel Pérez miguel-perez

View GitHub Profile
@miguel-perez
miguel-perez / a-b-test.js
Created May 11, 2016 17:51
Inject desired changes to a site using javascript
// IIFE for protection
;(function(win, doc, $){
var
newStyles = [
'<style>',
'.home .navbar-inverse .navbar-nav > li a:hover {',
'background-color: #f56226;',
'transition: background-color ease-in-out 0.5s;',
'}',
@miguel-perez
miguel-perez / footer.html
Last active October 9, 2015 14:12
LWF New Header / Footer
<p>Hello world</p>
@miguel-perez
miguel-perez / readyExec.js
Last active January 29, 2023 18:04
How to add the ability to re-run $(document).ready() functions
/**
* Replace jQuery's $.fn.ready() function with a mod exec
*
* Sites that make heavy use of the $(document).ready function
* are generally incompatable with asynchrounous content. The
* the $.fn.ready function only runs once. This script replaces
* the ready function with a module execution controller that
* let's us register functions and execute all of the functions
* as we need them. This is useful after HTML gets injected on the
* page and we want to rebind functionally to the new content.
@miguel-perez
miguel-perez / test.js
Created August 6, 2014 21:50
StackOverflow
var
/**
* Fires a custom event when all animations are complete
* @param {object} $element - jQuery object that should trigger event
*
*/
triggerAllAnimationEndEvent = function ($element) {
var animationCount = 0,
animationstart = "animationstart webkitAnimationStart oanimationstart MSAnimationStart",
@miguel-perez
miguel-perez / initSmoothState.js
Created August 5, 2014 15:57
New smoothState signature
// Contents of functions.js
;(function($) {
'use strict';
var $body = $('html, body'),
content = $('#main').smoothState({
// Runs when a link has been activated
onStart: function(url, $container) {
// toggleAnimationClass() is a public method
// for restarting css animations with a class
content.toggleAnimationClass('is-exiting');
@miguel-perez
miguel-perez / disqus.js
Created August 5, 2014 13:27
Disqus and smoothState.js
// DISQUS
var MP = MP || {};
MP.comments = {
init: function(){
"use strict";
var disqus_shortname = 'miguelperez';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
@miguel-perez
miguel-perez / README.md
Last active August 29, 2015 14:04
An example of page transitions with jQuery.smoothState.js