Skip to content

Instantly share code, notes, and snippets.

View JLevstein's full-sized avatar

Jonathan Levstein JLevstein

View GitHub Profile
@JLevstein
JLevstein / jQuery - Has image loaded?
Created August 31, 2013 23:07
jQuery - Has image loaded?
$(‘#imageID’).attr(‘src’, ‘imagefile.jpg’).load(function() {</pre>  Alert(‘image load successful’);  });
@JLevstein
JLevstein / jQuery - Reload part of page
Created August 31, 2013 23:08
jQuery - Reload part of page
setInterval(function() {   $(“#block”).load(location.href+”#block>*”,””);  }, 2000);
var sidekicks = [
{ name: "Robin", hero: "Batman" },
{ name: "Supergirl", hero: "Superman" },
{ name: "Oracle", hero: "Batman" },
{ name: "Krypto", hero: "Superman" }
];
var batKicks = sidekicks.filter(function (el) {
return (el.hero === "Batman");
});
@mixin transition($transition-property, $transition-time, $method) {
-webkit-transition: $transition-property $transition-time $method;
-moz-transition: $transition-property $transition-time $method;
-ms-transition: $transition-property $transition-time $method;
-o-transition: $transition-property $transition-time $method;
transition: $transition-property $transition-time $method;
}
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $http, $cacheFactory) {
// using $cacheFactory to make sure we clear
// the cache and then re-set it when cache is false
// in $scope.makeRequest
var httpCache = $cacheFactory.get('$http');
$scope.makeRequest = function (cache) {
if(!cache) httpCache.remove('response.php');
(function($) {
$.fn.drags = function(opt) {
opt = $.extend({handle:"",cursor:"move"}, opt);
if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}
function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
/* From Modernizr */
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd',
'MsTransition':'msTransitionEnd'
<div class="center-contain">
<div class="center-this"> Everything in this div will be centered in IE8 or greater</div>
</div>