Table of Contents generated with DocToc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function UndoItem (perform, data) { | |
this.perform = perform; | |
this.data = data; | |
} | |
/** | |
* UndoStack: | |
* Easy undo-redo in JavaScript. | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Auto update cart after quantity change | |
* | |
* @return string | |
**/ | |
add_action( 'woocommerce_after_cart', 'custom_after_cart' ); | |
function custom_after_cart() { | |
echo '<script> | |
jQuery(document).ready(function($) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementsByTagName('button')[0].onclick = function () { | |
scrollTo(document.body, 0, 1250); | |
} | |
function scrollTo(element, to, duration) { | |
var start = element.scrollTop, | |
change = to - start, | |
currentTime = 0, | |
increment = 20; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Ajax { | |
get(url, callback) { | |
let xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); | |
xhr.open('GET', url); | |
xhr.onreadystatechange = () => { | |
if (xhr.readyState > 3 && xhr.status === 200) { | |
callback(xhr.responseText); | |
} | |
}; | |
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ak_convert_hex2rgba($color, $opacity = false) { | |
$default = 'rgb(0,0,0)'; | |
if (empty($color)) | |
return $default; | |
if ($color[0] == '#') | |
$color = substr($color, 1); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @link https://frontendmasters.com/courses/javascript-the-good-parts/ | |
Problems 1-5 | |
A sequence of problems will be presented followed by a solution. Each problem builds on the last so if you get a problem wrong, use the solution to begin the next problem. First, a quick quiz: What is x? | |
3:19:33 - 3:32:25 | |
Problems 6-9 | |
o Problem 6: Write a function that takes a function and an argument, and returns a function that can supply a second argument. | |
o Problem 7: Without writing any new functions, show three ways to create the inc function. | |
o Problem 8: Write methodize, a function that converts a binary function to a method. | |
o Problem 9: Write demethodize, a function that converts a method to a binary function. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taphover - a solution to the lack of hover on touch devices. | |
//more info: http://www.hnldesign.nl/work/code/mouseover-hover-on-touch-devices-using-jquery/ | |
$('a.taphover').on('touchstart', function (e) { | |
'use strict'; //satisfy the code inspectors | |
var link = $(this); //preselect the link | |
if (link.hasClass('hover')) { | |
return true; | |
} else { | |
link.addClass('hover'); | |
$('a.taphover').not(this).removeClass('hover'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global $woocommerce; | |
if ( sizeof( $woocommerce->cart->cart_contents) > 0 ) : | |
echo '<a href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __( 'Checkout' ) . '">' . __( 'Checkout' ) . '</a>'; | |
endif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_get_attachment_url', function( $url, $id ){ | |
if( is_ssl() ) | |
$url = str_replace( 'http://', 'https://', $url ); | |
return $url; | |
}); |
NewerOlder