JSFiddle - React, Tailwind, and code Playground
by drvespa
HTML
<button class="btnUploadFile">
Upload
</button>
JavaScript
/**
* Ajax upload
* Project page - http://valums.com/ajax-upload/
* Copyright (c) 2008 Andris Valums, http://valums.com
* Licensed under the MIT license (http://valums.com/mit-license/)
* Version 3.6 (26.06.2009)
*/
/**
* Changes from the previous version:
* 1. Fixed minor bug where click outside the button
* would open the file browse window
*
* For the full changelog please visit:
* http://valums.com/ajax-upload-changelog/
*/
(function () {
var d = document, w = window;
/**
* Get element by id
*/
function get(element) {
if (typeof element == "string")
element = d.getElementById(element);
return element;
}
/**
* Attaches event to a dom element
*/
function addEvent(el, type, fn) {
if (w.addEventListener) {
el.addEventListener(type, fn, false);
} else if (w.attachEvent) {
var f = function () {
fn.call(el, w.event);
};
el.attachEvent('on' + type, f)
}
}
/**
* Creates and returns element from html chunk
*/
var toElement = function () {
var div = d.createElement('div');
return function (html) {
div.innerHTML = html;
var el = div.childNodes[0];
div.removeChild(el);
return el;
}
} ();
function hasClass(ele, cls) {
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}
function addClass(ele, cls) {
if (!hasClass(ele, cls)) ele.className += " " + cls;
}
function removeClass(ele, cls) {
var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
ele.className = ele.className.replace(reg, ' ');
}
// getOffset function copied from jQuery lib (http://jquery.com/)
if (document.documentElement["getBoundingClientRect"]) {
// Get Offset using getBoundingClientRect
// http://ejohn.org/blog/getboundingclientrect-is-awesome/
var...