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
var myWidgets = myWidgets || {}; | |
// Model for a single testimonial | |
myWidgets.Testimonial = Backbone.Model.extend({ | |
defaults: { 'quote': '', 'author': '' } | |
}); | |
// Single view, responsible for rendering and manipulation of each single testimonial | |
myWidgets.TestimonialView = Backbone.View.extend( { |
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 all of this tu custom page template ?> | |
<?php | |
global $wpdb; | |
$error = ''; | |
$success = ''; | |
// check if we're in reset form | |
if( isset( $_POST['action'] ) && 'reset' == $_POST['action'] ) | |
{ |
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
//Check for Required field and if it empty set to error state | |
function setInputToEdit(id){ | |
var a = document.getElementById(id); | |
var b = a.parentNode.getElementsByClassName('error-msg'); | |
a.parentNode.classList.add('error-input'); | |
} | |
//Check is all requred fields have value on fieldset | |
function passForRequired(input){ | |
var a = input.context.parentElement, // parent with inputs and selects | |
b = true, |
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
//enable async defer for Google Maps Library | |
//google_map_api -- name of before registred script | |
<?php | |
add_filter( 'script_loader_tag', function ( $tag, $handle ) { | |
if ( 'google_map_api' !== $handle ) | |
return $tag; | |
return str_replace( ' src', ' async defer src', $tag ); | |
}, 10, 2 ); |
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
//@param input = id of form, string | |
//@return c = return JSON object | |
function formDataToJson(input){ | |
//var a not used before | |
var a = document.getElementById(input), | |
b = $(input).serializeArray(), | |
c = {}; | |
for (var i = 0 ; i < b.length; i++) { | |
c[b[i].name] = b[i].value; |
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
/* | |
* FACEBOOK_URL - url from Facebook iframe snippert https://goo.gl/EUcaEn | |
* | |
*/ | |
<iframe id="ifr" data-url="FACEBOOK_URL" width="100%" height="189" style="border:none;overflow:hidden"></iframe> | |
<script> | |
$(window).on('load', function() { | |
var a = $('#ifr'); | |
if(a[0].src == ''){ | |
setTimeout(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
<!-- Google Maps --> | |
<script type="text/javascript"> | |
$(window).on('load', function(){ | |
setTimeout(function() { | |
var s = document.createElement('script'); | |
s.type = 'text/javascript'; | |
s.src = 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap'; | |
s.setAttribute('async', 'defer'); | |
document.getElementsByTagName('footer')[0].appendChild(s); |
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
// @input string, YouTube video url | |
// @return string, YouTube video ID | |
function getVideoId(input) { | |
return input.match(/(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/user\/\S+|\/ytscreeningroom\?v=|\/sandalsResorts#\w\/\w\/.*\/))([^\/&]{10,12})/)[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
/* | |
*$str - string to change | |
* | |
* | |
*/ | |
function camelCase($str, array $noStrip = []) | |
{ | |
// non-alpha and non-numeric characters become spaces | |
$str = preg_replace('/[^a-z0-9' . implode("", $noStrip) . ']+/i', ' ', $str); | |
$str = trim($str); |
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
<script type="text/javascript"> | |
$(window).on('mousewheel', function(e){ | |
var delta = e.originalEvent.detail < 0 || e.originalEvent.wheelDelta > 0 ? 1 : -1; | |
if (delta < 0){ | |
console.log('down'); | |
} else{ | |
console.log('up'); | |
} | |
}) | |
</script> |