Skip to content

Instantly share code, notes, and snippets.

@rozmiarek
rozmiarek / ajaxfileupload.js
Created April 26, 2012 20:41 — forked from HenrikJoreteg/ajaxfileupload.js
AJAX file uploading using jQuery and XMLHttpRequest 2.0 and adding listener for progress updates
// grab your file object from a file input
$('#fileInput').change(function () {
sendFile(this.files[0]);
});
// can also be from a drag-from-desktop drop
$('dropZone')[0].ondrop = function (e) {
e.preventDefault();
sendFile(e.dataTransfer.files[0]);
};
@rozmiarek
rozmiarek / gist:2350398
Created April 10, 2012 10:51
PubSub based on jQuery.Callback
define(['jquery'], function ($) {
var topics = {},
topic = function (id) {
var fn = this.toString(),
args = [].slice.call(arguments, 1);
(topics[id] = topics[id] || $.Callbacks())[fn].apply(null, args);
};
return {
pub: function () { topic.apply('fire', arguments); },
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
}
.cf:after {
clear:both;
}
@rozmiarek
rozmiarek / js: file template (jQuery based)
Created July 10, 2010 22:18
js: file template (jQuery based)
(function ($, window, undefined) {
$(function () {
// your js code here
});
})(jQuery, window);
@rozmiarek
rozmiarek / css: overflow hidden alternative
Created July 10, 2010 21:38
css: overflow hidden alternative
.elementWithFloatedChilds { height: 1%; }
.elementWithFloatedChilds:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}