/*! UIkit 2.6.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */

!function(a){var b;jQuery&&jQuery.UIkit&&(b=a(jQuery,jQuery.UIkit)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return b||a(jQuery,jQuery.UIkit)})}(function(a,b){function c(e,f){function g(b,c){var d=new FormData,e=new XMLHttpRequest;if(c.before(c,b)!==!1){for(var f,g=0;f=b[g];g++)d.append(c.param,f);for(var h in c.params)d.append(h,c.params[h]);e.upload.addEventListener("progress",function(a){var b=a.loaded/a.total*100;c.progress(b,a)},!1),e.addEventListener("loadstart",function(a){c.loadstart(a)},!1),e.addEventListener("load",function(a){c.load(a)},!1),e.addEventListener("loadend",function(a){c.loadend(a)},!1),e.addEventListener("error",function(a){c.error(a)},!1),e.addEventListener("abort",function(a){c.abort(a)},!1),e.open(c.method,c.action,!0),e.onreadystatechange=function(){if(c.readystatechange(e),4==e.readyState){var b=e.responseText;if("json"==c.type)try{b=a.parseJSON(b)}catch(d){b=!1}c.complete(b,e)}},e.send(d)}}if(!b.support.ajaxupload)return this;if(f=a.extend({},c.defaults,f),e.length){if("*.*"!==f.allow)for(var h,i=0;h=e[i];i++)if(!d(f.allow,h.name))return void("string"==typeof f.notallowed?alert(f.notallowed):f.notallowed(h,f));var j=f.complete;if(f.single){var k=e.length,l=0;f.complete=function(a,b){l+=1,j(a,b),k>l?g([e[l]],f):f.allcomplete(a,b)},g([e[0]],f)}else f.complete=function(a,b){j(a,b),f.allcomplete(a,b)},g(e,f)}}function d(a,b){var c="^"+a.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return c="^"+c+"$",null!==b.match(new RegExp(c,"i"))}return b.component("uploadSelect",{init:function(){var a=this;this.on("change",function(){c(a.element[0].files,a.options)})}}),b.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var a=this,b=!1;this.on("drop",function(b){b.dataTransfer&&b.dataTransfer.files&&(b.stopPropagation(),b.preventDefault(),a.element.removeClass(a.options.dragoverClass),c(b.dataTransfer.files,a.options))}).on("dragenter",function(a){a.stopPropagation(),a.preventDefault()}).on("dragover",function(c){c.stopPropagation(),c.preventDefault(),b||(a.element.addClass(a.options.dragoverClass),b=!0)}).on("dragleave",function(c){c.stopPropagation(),c.preventDefault(),a.element.removeClass(a.options.dragoverClass),b=!1})}}),b.support.ajaxupload=function(){function a(){var a=document.createElement("INPUT");return a.type="file","files"in a}function b(){var a=new XMLHttpRequest;return!!(a&&"upload"in a&&"onprogress"in a.upload)}function c(){return!!window.FormData}return a()&&b()&&c()}(),b.support.ajaxupload&&a.event.props.push("dataTransfer"),c.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",before:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(a,b){alert("Only the following file types are allowed: "+b.allow)}},b.Utils.xhrupload=c,c});