/*! UIkit 2.5.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ (function(addon) { if (typeof define == "function" && define.amd) { // AMD define(["uikit"], function(){ return jQuery.UIkit || addon(window.jQuery, window.jQuery.UIkit); }); } if (window && window.jQuery && window.jQuery.UIkit) { addon(window.jQuery, window.jQuery.UIkit); } })(function($, UI){ var UploadSelect = function(element, options) { var $this = this, $element = $(element), options = $.extend({}, xhrupload.defaults, UploadSelect.defaults, options); if ($element.data("uploadSelect")) return; this.element = $element.on("change", function() { xhrupload($this.element[0].files, options); }); $element.data("uploadSelect", this); }; UploadSelect.defaults = {}; var UploadDrop = function(element, options) { var $this = this, $element = $(element), options = $.extend({}, xhrupload.defaults, UploadDrop.defaults, options), hasdragCls = false; if ($element.data("uploadDrop")) return; $element.on("drop", function(e){ if (e.dataTransfer && e.dataTransfer.files) { e.stopPropagation(); e.preventDefault(); $element.removeClass(options.dragoverClass); xhrupload(e.dataTransfer.files, options); } }).on("dragenter", function(e){ e.stopPropagation(); e.preventDefault(); }).on("dragover", function(e){ e.stopPropagation(); e.preventDefault(); if (!hasdragCls) { $element.addClass(options.dragoverClass); hasdragCls = true; } }).on("dragleave", function(e){ e.stopPropagation(); e.preventDefault(); $element.removeClass(options.dragoverClass); hasdragCls = false; }); $element.data("uploadDrop", this); }; UploadDrop.defaults = { 'dragoverClass': 'uk-dragover' }; UI["upload"] = { "select" : UploadSelect, "drop" : UploadDrop }; UI.support.ajaxupload = (function() { function supportFileAPI() { var fi = document.createElement('INPUT'); fi.type = 'file'; return 'files' in fi; } function supportAjaxUploadProgressEvents() { var xhr = new XMLHttpRequest(); return !! (xhr && ('upload' in xhr) && ('onprogress' in xhr.upload)); } function supportFormData() { return !! window.FormData; } return supportFileAPI() && supportAjaxUploadProgressEvents() && supportFormData(); })(); if (UI.support.ajaxupload){ $.event.props.push("dataTransfer"); } function xhrupload(files, settings) { if (!UI.support.ajaxupload){ return this; } settings = $.extend({}, xhrupload.defaults, settings); if (!files.length){ return; } if (settings.allow !== '*.*') { for(var i=0,file;file=files[i];i++) { if(!matchName(settings.allow, file.name)) { if(typeof(settings.notallowed) == 'string') { alert(settings.notallowed); } else { settings.notallowed(file, settings); } return; } } } var complete = settings.complete; if (settings.single){ var count = files.length, uploaded = 0; settings.complete = function(response, xhr){ uploaded = uploaded+1; complete(response, xhr); if (uploaded