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 nextimage = "/images/some-image.jpg"; | |
$(document).ready(function() | |
{ | |
window.setTimeout(function() | |
{ | |
var img = $("<img>").attr("src", nextimage).load(function(){ | |
//all done | |
}); | |
}, 100); | |
}); |
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 getMaxHeight = function ($elms) { | |
var maxHeight = 0; | |
$elms.each(function () { | |
// In some cases you may want to use outerHeight() instead | |
var height = $(this).height(); | |
if (height > maxHeight) { | |
maxHeight = height; | |
} | |
}); | |
return maxHeight; |
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 isValidDate(value, userFormat) { | |
// Set default format if format is not provided | |
userFormat = userFormat || ‘mm/dd/yyyy’; | |
// Find custom delimiter by excluding | |
// month, day and year characters | |
var delimiter = /[^mdy]/.exec(userFormat)[0]; | |
// Create an array with month, day and year | |
// so we know the format order by index | |
var theFormat = userFormat.split(delimiter); | |
// Create array from user date |
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 embedYoutube(link, ops) { | |
var o = $.extend({ | |
width: 480, | |
height: 320, | |
params: '' | |
}, ops); | |
var id = /\?v\=(\w+)/.exec(link)[1]; | |
return '<iframe style="display: block;" type="text/html" ' + | |
' width="' + o.width + '" height="' + o.height + '"' + | |
' src="http://www.youtube.com/embed/' + id + '?' + o.params + |
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 isValidEmail(string) { | |
string = string||''; | |
var lastseg = (string.split('@')[1]||'').split('.')[1]||'', | |
input = document.createElement('input'); | |
input.type = 'email'; | |
input.required = true; | |
input.value = string; | |
return !!(string && (input.validity && | |
input.validity.valid) && |
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 getAbsoluteUrl = (function() { | |
var a; | |
return function(url) { | |
if(!a) a = document.createElement('a'); | |
a.href = url; | |
return a.href; | |
}; | |
})(); | |
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() { | |
'use strict'; | |
// click events | |
document.body.addEventListener('click', copy, true); | |
// event handler | |
function copy(e) { | |
// find target element | |
var |